superblock: mask getattr requests with supported_attrs

on creation of a new superblock, construct a bitmap for the default attribute mask to be used for GETATTR and READDIR requests on that filesystem.  mask out any unsupported attributes, and store the bitmap in the field nfs41_superblock.default_getattr

replaced function init_getattr_request() with nfs41_superblock_getattr_mask(), which returns a copy of superblock->default_getattr

removed the locking in nfs41_superblock_supported_attrs() and nfs41_superblock_supported_attrs_exclcreat(), as the supported_attrs and suppattr_exclcreat fields are read-only after the superblock is first initialized.  also factored out their common code into a bitmap_intersect() function in util.h

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2012-04-02 14:22:58 -04:00 committed by unknown
parent b955b6d3fe
commit c59124dd20
9 changed files with 65 additions and 71 deletions

View file

@ -127,6 +127,20 @@ static int get_superblock_attrs(
if (!bitmap_isset(&info.attrmask, 1, FATTR4_WORD1_TIME_DELTA))
superblock->time_delta.seconds = 1;
/* initialize the default getattr mask */
superblock->default_getattr.count = 2;
superblock->default_getattr.arr[0] = FATTR4_WORD0_TYPE
| FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE
| FATTR4_WORD0_FILEID | FATTR4_WORD0_HIDDEN
| FATTR4_WORD0_ARCHIVE;
superblock->default_getattr.arr[1] = FATTR4_WORD1_MODE
| FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_SYSTEM
| FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_CREATE
| FATTR4_WORD1_TIME_MODIFY;
superblock->default_getattr.arr[2] = 0;
nfs41_superblock_supported_attrs(superblock, &superblock->default_getattr);
dprintf(SBLVL, "attributes for fsid(%llu,%llu): "
"maxread=%llu, maxwrite=%llu, layout_types: 0x%X, "
"cansettime=%u, time_delta={%llu,%u}, aclsupport=%u, "
@ -245,38 +259,6 @@ out:
return status;
}
void nfs41_superblock_supported_attrs(
IN nfs41_superblock *superblock,
IN OUT bitmap4 *attrs)
{
uint32_t i, count = 0;
AcquireSRWLockShared(&superblock->lock);
for (i = 0; i < 3; i++) {
attrs->arr[i] &= superblock->supported_attrs.arr[i];
if (attrs->arr[i])
count = i+1;
}
attrs->count = min(attrs->count, count);
ReleaseSRWLockShared(&superblock->lock);
}
void nfs41_superblock_supported_attrs_exclcreat(
IN nfs41_superblock *superblock,
IN OUT bitmap4 *attrs)
{
uint32_t i, count = 0;
AcquireSRWLockShared(&superblock->lock);
for (i = 0; i < 3; i++) {
attrs->arr[i] &= superblock->suppattr_exclcreat.arr[i];
if (attrs->arr[i])
count = i+1;
}
attrs->count = min(attrs->count, count);
ReleaseSRWLockShared(&superblock->lock);
}
void nfs41_superblock_space_changed(
IN nfs41_superblock *superblock)
{