diff --git a/daemon/nfs41_compound.c b/daemon/nfs41_compound.c index 436c268..fe116a9 100644 --- a/daemon/nfs41_compound.c +++ b/daemon/nfs41_compound.c @@ -40,53 +40,24 @@ int compound_error(int status) return status; } -static void compound_args_init( - nfs41_compound_args *compound, - nfs_argop4 *argarray, - const char *tag) -{ - compound->tag_len = (uint32_t)strlen(tag); - memcpy(compound->tag, tag, compound->tag_len); - compound->minorversion = 1; - compound->argarray_count = 0; - compound->argarray = argarray; -} - -static void compound_args_add_op( - nfs41_compound_args *compound, - uint32_t opnum, - void *arg) -{ - const uint32_t i = compound->argarray_count++; - compound->argarray[i].op = opnum; - compound->argarray[i].arg = arg; -} - -static void compound_res_init( - nfs41_compound_res *compound, - nfs_resop4 *resarray) -{ - ZeroMemory(compound, sizeof(nfs41_compound_res)); - compound->tag_len = NFS4_OPAQUE_LIMIT; - compound->resarray_count = 0; - compound->resarray = resarray; -} - -static void compound_res_add_op( - nfs41_compound_res *compound, - void *res) -{ - compound->resarray[compound->resarray_count++].res = res; -} - void compound_init( nfs41_compound *compound, nfs_argop4 *argops, nfs_resop4 *resops, const char *tag) { - compound_args_init(&compound->args, argops, tag); - compound_res_init(&compound->res, resops); + /* initialize args */ + compound->args.tag_len = (uint32_t)strlen(tag); + memcpy(compound->args.tag, tag, compound->args.tag_len); + compound->args.minorversion = 1; + compound->args.argarray_count = 0; + compound->args.argarray = argops; + + /* initialize results */ + ZeroMemory(&compound->res, sizeof(nfs41_compound_res)); + compound->res.tag_len = NFS4_OPAQUE_LIMIT; + compound->res.resarray_count = 0; + compound->res.resarray = resops; } void compound_add_op( @@ -95,8 +66,11 @@ void compound_add_op( void *arg, void *res) { - compound_args_add_op(&compound->args, opnum, arg); - compound_res_add_op(&compound->res, res); + const uint32_t i = compound->args.argarray_count++; + compound->args.argarray[i].op = opnum; + compound->args.argarray[i].arg = arg; + + compound->res.resarray[compound->res.resarray_count++].res = res; } /* Due to the possibility of replays, we might get a response to a different diff --git a/daemon/nfs41_server.c b/daemon/nfs41_server.c index 236098f..61e21e0 100644 --- a/daemon/nfs41_server.c +++ b/daemon/nfs41_server.c @@ -226,8 +226,8 @@ int nfs41_server_find_or_create( EnterCriticalSection(&g_server_list.lock); /* search for an existing server */ - status = server_entry_find(&g_server_list, &info, &entry); - if (status) { + entry = list_search(&g_server_list.head, &info, server_compare); + if (entry == NULL) { /* create a new server */ status = server_create(&info, &server); if (status == NO_ERROR) { @@ -243,6 +243,7 @@ int nfs41_server_find_or_create( } } else { server = server_entry(entry); + status = NO_ERROR; dprintf(SRVLVL, "<-- nfs41_server_find_or_create() " "returning existing server %p\n", server); diff --git a/daemon/nfs41_superblock.c b/daemon/nfs41_superblock.c index 1c33e0c..6389294 100644 --- a/daemon/nfs41_superblock.c +++ b/daemon/nfs41_superblock.c @@ -72,12 +72,6 @@ out: return status; } -static void superblock_free( - IN nfs41_superblock *superblock) -{ - free(superblock); -} - static int get_superblock_attrs( IN nfs41_session *session, IN nfs41_superblock *superblock, @@ -175,7 +169,7 @@ void nfs41_superblock_list_free( dprintf(SBLVL, "nfs41_superblock_list_free()\n"); list_for_each_tmp(entry, tmp, &superblocks->head) - superblock_free(superblock_entry(entry)); + free(superblock_entry(entry)); } diff --git a/daemon/pnfs_device.c b/daemon/pnfs_device.c index 5439703..cc731a7 100644 --- a/daemon/pnfs_device.c +++ b/daemon/pnfs_device.c @@ -77,15 +77,6 @@ static int deviceid_compare( return memcmp(device->device.deviceid, deviceid, PNFS_DEVICEID_SIZE); } -static enum pnfs_status file_device_entry_find( - IN struct pnfs_file_device_list *devices, - IN const unsigned char *deviceid, - OUT struct list_entry **entry_out) -{ - *entry_out = list_search(&devices->head, deviceid, deviceid_compare); - return *entry_out ? PNFS_SUCCESS : PNFSERR_NO_DEVICE; -} - static enum pnfs_status file_device_find_or_create( IN const unsigned char *deviceid, IN struct pnfs_file_device_list *devices, @@ -99,8 +90,8 @@ static enum pnfs_status file_device_find_or_create( EnterCriticalSection(&devices->lock); /* search for an existing device */ - status = file_device_entry_find(devices, deviceid, &entry); - if (status) { + entry = list_search(&devices->head, deviceid, deviceid_compare); + if (entry == NULL) { /* create a new device */ pnfs_file_device *device; status = file_device_create(deviceid, &device); @@ -117,6 +108,7 @@ static enum pnfs_status file_device_find_or_create( } } else { *device_out = device_entry(entry); + status = PNFS_SUCCESS; dprintf(FDLVL, "<-- pnfs_file_device_find_or_create() " "returning existing device %p\n", *device_out); @@ -164,12 +156,6 @@ void pnfs_file_device_list_free( /* pnfs_file_device */ -static enum pnfs_status file_device_status( - IN pnfs_file_device *device) -{ - return device->device.type == 0 ? PNFS_PENDING : PNFS_SUCCESS; -} - enum pnfs_status pnfs_file_device_get( IN nfs41_session *session, IN struct pnfs_file_device_list *devices, @@ -187,13 +173,13 @@ enum pnfs_status pnfs_file_device_get( goto out; AcquireSRWLockShared(&device->lock); - status = file_device_status(device); + status = device->device.type == 0 ? PNFS_PENDING : PNFS_SUCCESS; ReleaseSRWLockShared(&device->lock); if (status == PNFS_PENDING) { AcquireSRWLockExclusive(&device->lock); - status = file_device_status(device); + status = device->device.type == 0 ? PNFS_PENDING : PNFS_SUCCESS; if (status == PNFS_PENDING) { nfsstat = pnfs_rpc_getdeviceinfo(session, deviceid, device); if (nfsstat == NFS4_OK) { diff --git a/daemon/pnfs_layout.c b/daemon/pnfs_layout.c index 137e004..f19a281 100644 --- a/daemon/pnfs_layout.c +++ b/daemon/pnfs_layout.c @@ -239,45 +239,20 @@ static enum pnfs_status file_layout_fetch( return pnfsstat; } -static bool_t layout_recalled( - IN const pnfs_layout *layout) -{ - return (layout->status & PNFS_LAYOUT_RECALLED) != 0; -} - -static bool_t layout_granted( - IN const pnfs_layout *layout) -{ - return (layout->status & PNFS_LAYOUT_GRANTED) != 0; -} - -static bool_t layout_not_rw( - IN const pnfs_layout *layout) -{ - return (layout->status & PNFS_LAYOUT_NOT_RW) != 0; -} - -static bool_t will_never_grant( - IN const pnfs_layout *layout, - IN enum pnfs_iomode iomode) -{ - return (layout->status & PNFS_LAYOUT_UNAVAILABLE) != 0 - || (iomode == PNFS_IOMODE_RW && layout_not_rw(layout)); -} - static enum pnfs_status layout_grant_status( IN const pnfs_layout *layout, IN enum pnfs_iomode iomode) { enum pnfs_status status = PNFS_PENDING; - if (layout_recalled(layout)) { + if (layout->status & PNFS_LAYOUT_RECALLED) { /* don't use a recalled layout */ status = PNFSERR_LAYOUT_RECALLED; - } else if (layout_granted(layout)) { + } else if (layout->status & PNFS_LAYOUT_GRANTED) { /* the layout is granted; use it if it's compatible */ status = PNFS_SUCCESS; - } else if (will_never_grant(layout, iomode)) { + } else if ((layout->status & PNFS_LAYOUT_UNAVAILABLE) || + (iomode == PNFS_IOMODE_RW && layout->status & PNFS_LAYOUT_NOT_RW)) { /* an error from LAYOUTGET indicated that the server * won't ever grant this layout, so stop trying */ status = PNFSERR_NOT_SUPPORTED; @@ -311,7 +286,7 @@ static enum pnfs_status file_layout_cache( if (layout->layout.state.seqid) state = &layout->layout.state; - if (!layout_not_rw(&layout->layout)) { + if ((layout->layout.status & PNFS_LAYOUT_NOT_RW) == 0) { /* try to get a RW layout first */ status = file_layout_fetch(layout, session, meta_file, state, PNFS_IOMODE_RW, offset, length); @@ -358,7 +333,7 @@ static enum pnfs_status file_device_status( { enum pnfs_status status = PNFS_PENDING; - if (layout_recalled(layout)) { + if (layout->status & PNFS_LAYOUT_RECALLED) { /* don't fetch deviceinfo for a recalled layout */ status = PNFSERR_LAYOUT_RECALLED; } else if (layout->status & PNFS_LAYOUT_HAS_DEVICE) { @@ -797,7 +772,7 @@ enum pnfs_status pnfs_layout_io_start( AcquireSRWLockExclusive(&layout->lock); - if (layout_recalled(layout)) { + if ((layout->status & PNFS_LAYOUT_RECALLED) != 0) { /* don't start any more io if the layout has been recalled */ status = PNFSERR_LAYOUT_RECALLED; dprintf(FLLVL, "pnfs_layout_io_start() failed, layout was recalled\n"); diff --git a/daemon/readdir.c b/daemon/readdir.c index 7ef8a33..dc350bd 100644 --- a/daemon/readdir.c +++ b/daemon/readdir.c @@ -80,12 +80,6 @@ out: #define FILTER_STAR '*' #define FILTER_QM '>' -static __inline int readdir_has_wildcards( - const char *filter) -{ - return strchr(filter, FILTER_STAR) || strchr(filter, FILTER_QM); -} - static __inline const char* skip_stars( const char *filter) { @@ -505,7 +499,7 @@ fetch_entries: init_getattr_request(&attr_request); attr_request.arr[0] |= FATTR4_WORD0_RDATTR_ERROR; - if (readdir_has_wildcards((const char*)args->filter)) { + if (strchr(args->filter, FILTER_STAR) || strchr(args->filter, FILTER_QM)) { /* use READDIR for wildcards */ uint32_t dots_len = 0;