diff options
author | Charles Manning <cdhmanning@gmail.com> | 2010-09-09 09:20:23 +1200 |
---|---|---|
committer | Charles Manning <cdhmanning@gmail.com> | 2010-09-09 09:20:23 +1200 |
commit | de6470acd795b2daab5372dd4a9edce3f186afea (patch) | |
tree | 0e136a0e66b52ba05f8804d25fc8bce94de0ace2 /yaffs_guts.c | |
parent | 0035e396dc2b872289b8e6320ced59e2eea81962 (diff) |
yaffs: Cache object xattrib state.
We cache whether or not an object has xattributes.
This is done to get around the problem of the Linux VFS trying to check security
capabilities on every write. Assuming that most files don't have security
attributes, this code will save on a huge amount of reads and make writing
faster.
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
Diffstat (limited to 'yaffs_guts.c')
-rw-r--r-- | yaffs_guts.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/yaffs_guts.c b/yaffs_guts.c index 75eeb84..6ea5698 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -66,7 +66,7 @@ static yaffs_Object *yaffs_CreateNewObject(yaffs_Device *dev, int number, yaffs_ObjectType type); -static int yaffs_ApplyXMod(yaffs_Device *dev, char *buffer, yaffs_XAttrMod *xmod); +static int yaffs_ApplyXMod(yaffs_Object *obj, char *buffer, yaffs_XAttrMod *xmod); static void yaffs_RemoveObjectFromDirectory(yaffs_Object *obj); static int yaffs_CheckStructures(void); @@ -3112,7 +3112,7 @@ int yaffs_UpdateObjectHeader(yaffs_Object *in, const YCHAR *name, int force, /* process any xattrib modifications */ if(xmod) - yaffs_ApplyXMod(dev, (char *)buffer, xmod); + yaffs_ApplyXMod(in, (char *)buffer, xmod); /* Tags */ @@ -4939,10 +4939,11 @@ static int yaffs_DoXMod(yaffs_Object *obj, int set, const YCHAR *name, const voi return -ENOSPC; } -static int yaffs_ApplyXMod(yaffs_Device *dev, char *buffer, yaffs_XAttrMod *xmod) +static int yaffs_ApplyXMod(yaffs_Object *obj, char *buffer, yaffs_XAttrMod *xmod) { int retval = 0; int x_offs = sizeof(yaffs_ObjectHeader); + yaffs_Device *dev = obj->myDev; int x_size = dev->nDataBytesPerChunk - sizeof(yaffs_ObjectHeader); char * x_buffer = buffer + x_offs; @@ -4952,6 +4953,9 @@ static int yaffs_ApplyXMod(yaffs_Device *dev, char *buffer, yaffs_XAttrMod *xmod else retval = nval_del(x_buffer, x_size, xmod->name); + obj->hasXattr = nval_hasvalues(x_buffer, x_size); + obj->xattrKnown = 1; + xmod->result = retval; return retval; @@ -4973,6 +4977,16 @@ static int yaffs_DoXFetch(yaffs_Object *obj, const YCHAR *name, void *value, int if(obj->hdrChunk < 1) return -ENODATA; + /* If we know that the object has no xattribs then don't do all the + * reading and parsing. + */ + if(obj->xattrKnown && !obj->hasXattr){ + if(name) + return -ENODATA; + else + return 0; + } + buffer = yaffs_GetTempBuffer(dev, __LINE__); if(!buffer) return -ENOMEM; @@ -4984,6 +4998,11 @@ static int yaffs_DoXFetch(yaffs_Object *obj, const YCHAR *name, void *value, int else{ x_buffer = buffer + x_offs; + if (!obj->xattrKnown){ + obj->hasXattr = nval_hasvalues(x_buffer, x_size); + obj->xattrKnown = 1; + } + if(name) retval = nval_get(x_buffer, x_size, name, value, size); else |