cosmetic: cleaning up small functions
attempted to get rid of short functions that are only called from one place Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
parent
f70e454988
commit
38813e13d8
6 changed files with 34 additions and 110 deletions
|
|
@ -40,53 +40,24 @@ int compound_error(int status)
|
||||||
return 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(
|
void compound_init(
|
||||||
nfs41_compound *compound,
|
nfs41_compound *compound,
|
||||||
nfs_argop4 *argops,
|
nfs_argop4 *argops,
|
||||||
nfs_resop4 *resops,
|
nfs_resop4 *resops,
|
||||||
const char *tag)
|
const char *tag)
|
||||||
{
|
{
|
||||||
compound_args_init(&compound->args, argops, tag);
|
/* initialize args */
|
||||||
compound_res_init(&compound->res, resops);
|
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(
|
void compound_add_op(
|
||||||
|
|
@ -95,8 +66,11 @@ void compound_add_op(
|
||||||
void *arg,
|
void *arg,
|
||||||
void *res)
|
void *res)
|
||||||
{
|
{
|
||||||
compound_args_add_op(&compound->args, opnum, arg);
|
const uint32_t i = compound->args.argarray_count++;
|
||||||
compound_res_add_op(&compound->res, res);
|
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
|
/* Due to the possibility of replays, we might get a response to a different
|
||||||
|
|
|
||||||
|
|
@ -226,8 +226,8 @@ int nfs41_server_find_or_create(
|
||||||
EnterCriticalSection(&g_server_list.lock);
|
EnterCriticalSection(&g_server_list.lock);
|
||||||
|
|
||||||
/* search for an existing server */
|
/* search for an existing server */
|
||||||
status = server_entry_find(&g_server_list, &info, &entry);
|
entry = list_search(&g_server_list.head, &info, server_compare);
|
||||||
if (status) {
|
if (entry == NULL) {
|
||||||
/* create a new server */
|
/* create a new server */
|
||||||
status = server_create(&info, &server);
|
status = server_create(&info, &server);
|
||||||
if (status == NO_ERROR) {
|
if (status == NO_ERROR) {
|
||||||
|
|
@ -243,6 +243,7 @@ int nfs41_server_find_or_create(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
server = server_entry(entry);
|
server = server_entry(entry);
|
||||||
|
status = NO_ERROR;
|
||||||
|
|
||||||
dprintf(SRVLVL, "<-- nfs41_server_find_or_create() "
|
dprintf(SRVLVL, "<-- nfs41_server_find_or_create() "
|
||||||
"returning existing server %p\n", server);
|
"returning existing server %p\n", server);
|
||||||
|
|
|
||||||
|
|
@ -72,12 +72,6 @@ out:
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void superblock_free(
|
|
||||||
IN nfs41_superblock *superblock)
|
|
||||||
{
|
|
||||||
free(superblock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_superblock_attrs(
|
static int get_superblock_attrs(
|
||||||
IN nfs41_session *session,
|
IN nfs41_session *session,
|
||||||
IN nfs41_superblock *superblock,
|
IN nfs41_superblock *superblock,
|
||||||
|
|
@ -175,7 +169,7 @@ void nfs41_superblock_list_free(
|
||||||
dprintf(SBLVL, "nfs41_superblock_list_free()\n");
|
dprintf(SBLVL, "nfs41_superblock_list_free()\n");
|
||||||
|
|
||||||
list_for_each_tmp(entry, tmp, &superblocks->head)
|
list_for_each_tmp(entry, tmp, &superblocks->head)
|
||||||
superblock_free(superblock_entry(entry));
|
free(superblock_entry(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,15 +77,6 @@ static int deviceid_compare(
|
||||||
return memcmp(device->device.deviceid, deviceid, PNFS_DEVICEID_SIZE);
|
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(
|
static enum pnfs_status file_device_find_or_create(
|
||||||
IN const unsigned char *deviceid,
|
IN const unsigned char *deviceid,
|
||||||
IN struct pnfs_file_device_list *devices,
|
IN struct pnfs_file_device_list *devices,
|
||||||
|
|
@ -99,8 +90,8 @@ static enum pnfs_status file_device_find_or_create(
|
||||||
EnterCriticalSection(&devices->lock);
|
EnterCriticalSection(&devices->lock);
|
||||||
|
|
||||||
/* search for an existing device */
|
/* search for an existing device */
|
||||||
status = file_device_entry_find(devices, deviceid, &entry);
|
entry = list_search(&devices->head, deviceid, deviceid_compare);
|
||||||
if (status) {
|
if (entry == NULL) {
|
||||||
/* create a new device */
|
/* create a new device */
|
||||||
pnfs_file_device *device;
|
pnfs_file_device *device;
|
||||||
status = file_device_create(deviceid, &device);
|
status = file_device_create(deviceid, &device);
|
||||||
|
|
@ -117,6 +108,7 @@ static enum pnfs_status file_device_find_or_create(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*device_out = device_entry(entry);
|
*device_out = device_entry(entry);
|
||||||
|
status = PNFS_SUCCESS;
|
||||||
|
|
||||||
dprintf(FDLVL, "<-- pnfs_file_device_find_or_create() "
|
dprintf(FDLVL, "<-- pnfs_file_device_find_or_create() "
|
||||||
"returning existing device %p\n", *device_out);
|
"returning existing device %p\n", *device_out);
|
||||||
|
|
@ -164,12 +156,6 @@ void pnfs_file_device_list_free(
|
||||||
|
|
||||||
|
|
||||||
/* pnfs_file_device */
|
/* 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(
|
enum pnfs_status pnfs_file_device_get(
|
||||||
IN nfs41_session *session,
|
IN nfs41_session *session,
|
||||||
IN struct pnfs_file_device_list *devices,
|
IN struct pnfs_file_device_list *devices,
|
||||||
|
|
@ -187,13 +173,13 @@ enum pnfs_status pnfs_file_device_get(
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
AcquireSRWLockShared(&device->lock);
|
AcquireSRWLockShared(&device->lock);
|
||||||
status = file_device_status(device);
|
status = device->device.type == 0 ? PNFS_PENDING : PNFS_SUCCESS;
|
||||||
ReleaseSRWLockShared(&device->lock);
|
ReleaseSRWLockShared(&device->lock);
|
||||||
|
|
||||||
if (status == PNFS_PENDING) {
|
if (status == PNFS_PENDING) {
|
||||||
AcquireSRWLockExclusive(&device->lock);
|
AcquireSRWLockExclusive(&device->lock);
|
||||||
|
|
||||||
status = file_device_status(device);
|
status = device->device.type == 0 ? PNFS_PENDING : PNFS_SUCCESS;
|
||||||
if (status == PNFS_PENDING) {
|
if (status == PNFS_PENDING) {
|
||||||
nfsstat = pnfs_rpc_getdeviceinfo(session, deviceid, device);
|
nfsstat = pnfs_rpc_getdeviceinfo(session, deviceid, device);
|
||||||
if (nfsstat == NFS4_OK) {
|
if (nfsstat == NFS4_OK) {
|
||||||
|
|
|
||||||
|
|
@ -239,45 +239,20 @@ static enum pnfs_status file_layout_fetch(
|
||||||
return pnfsstat;
|
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(
|
static enum pnfs_status layout_grant_status(
|
||||||
IN const pnfs_layout *layout,
|
IN const pnfs_layout *layout,
|
||||||
IN enum pnfs_iomode iomode)
|
IN enum pnfs_iomode iomode)
|
||||||
{
|
{
|
||||||
enum pnfs_status status = PNFS_PENDING;
|
enum pnfs_status status = PNFS_PENDING;
|
||||||
|
|
||||||
if (layout_recalled(layout)) {
|
if (layout->status & PNFS_LAYOUT_RECALLED) {
|
||||||
/* don't use a recalled layout */
|
/* don't use a recalled layout */
|
||||||
status = PNFSERR_LAYOUT_RECALLED;
|
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 */
|
/* the layout is granted; use it if it's compatible */
|
||||||
status = PNFS_SUCCESS;
|
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
|
/* an error from LAYOUTGET indicated that the server
|
||||||
* won't ever grant this layout, so stop trying */
|
* won't ever grant this layout, so stop trying */
|
||||||
status = PNFSERR_NOT_SUPPORTED;
|
status = PNFSERR_NOT_SUPPORTED;
|
||||||
|
|
@ -311,7 +286,7 @@ static enum pnfs_status file_layout_cache(
|
||||||
if (layout->layout.state.seqid)
|
if (layout->layout.state.seqid)
|
||||||
state = &layout->layout.state;
|
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 */
|
/* try to get a RW layout first */
|
||||||
status = file_layout_fetch(layout, session,
|
status = file_layout_fetch(layout, session,
|
||||||
meta_file, state, PNFS_IOMODE_RW, offset, length);
|
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;
|
enum pnfs_status status = PNFS_PENDING;
|
||||||
|
|
||||||
if (layout_recalled(layout)) {
|
if (layout->status & PNFS_LAYOUT_RECALLED) {
|
||||||
/* don't fetch deviceinfo for a recalled layout */
|
/* don't fetch deviceinfo for a recalled layout */
|
||||||
status = PNFSERR_LAYOUT_RECALLED;
|
status = PNFSERR_LAYOUT_RECALLED;
|
||||||
} else if (layout->status & PNFS_LAYOUT_HAS_DEVICE) {
|
} else if (layout->status & PNFS_LAYOUT_HAS_DEVICE) {
|
||||||
|
|
@ -797,7 +772,7 @@ enum pnfs_status pnfs_layout_io_start(
|
||||||
|
|
||||||
AcquireSRWLockExclusive(&layout->lock);
|
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 */
|
/* don't start any more io if the layout has been recalled */
|
||||||
status = PNFSERR_LAYOUT_RECALLED;
|
status = PNFSERR_LAYOUT_RECALLED;
|
||||||
dprintf(FLLVL, "pnfs_layout_io_start() failed, layout was recalled\n");
|
dprintf(FLLVL, "pnfs_layout_io_start() failed, layout was recalled\n");
|
||||||
|
|
|
||||||
|
|
@ -80,12 +80,6 @@ out:
|
||||||
#define FILTER_STAR '*'
|
#define FILTER_STAR '*'
|
||||||
#define FILTER_QM '>'
|
#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(
|
static __inline const char* skip_stars(
|
||||||
const char *filter)
|
const char *filter)
|
||||||
{
|
{
|
||||||
|
|
@ -505,7 +499,7 @@ fetch_entries:
|
||||||
init_getattr_request(&attr_request);
|
init_getattr_request(&attr_request);
|
||||||
attr_request.arr[0] |= FATTR4_WORD0_RDATTR_ERROR;
|
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 */
|
/* use READDIR for wildcards */
|
||||||
|
|
||||||
uint32_t dots_len = 0;
|
uint32_t dots_len = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue