Skip to content

Commit

Permalink
afs: Prospectively look up extra files when doing a single lookup
Browse files Browse the repository at this point in the history
When afs_lookup() is called, prospectively look up the next 50 uncached
fids also from that same directory and cache the results, rather than just
looking up the one file requested.

This allows us to use the FS.InlineBulkStatus RPC op to increase efficiency
by fetching up to 50 file statuses at a time.

Signed-off-by: David Howells <[email protected]>
  • Loading branch information
dhowells committed Apr 9, 2018
1 parent 17814ae commit 5cf9dd5
Show file tree
Hide file tree
Showing 8 changed files with 552 additions and 63 deletions.
21 changes: 13 additions & 8 deletions fs/afs/afs.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ typedef enum {
} afs_callback_type_t;

struct afs_callback {
struct afs_fid fid; /* file identifier */
unsigned version; /* callback version */
unsigned expiry; /* time at which expires */
afs_callback_type_t type; /* type of callback */
unsigned version; /* Callback version */
unsigned expiry; /* Time at which expires */
afs_callback_type_t type; /* Type of callback */
};

struct afs_callback_break {
struct afs_fid fid; /* File identifier */
struct afs_callback cb; /* Callback details */
};

#define AFSCBMAX 50 /* maximum callbacks transferred per bulk op */
Expand Down Expand Up @@ -123,21 +127,22 @@ typedef u32 afs_access_t;
* AFS file status information
*/
struct afs_file_status {
u64 size; /* file size */
afs_dataversion_t data_version; /* current data version */
time_t mtime_client; /* last time client changed data */
time_t mtime_server; /* last time server changed data */
unsigned if_version; /* interface version */
#define AFS_FSTATUS_VERSION 1
unsigned abort_code; /* Abort if bulk-fetching this failed */

afs_file_type_t type; /* file type */
unsigned nlink; /* link count */
u64 size; /* file size */
afs_dataversion_t data_version; /* current data version */
u32 author; /* author ID */
kuid_t owner; /* owner ID */
kgid_t group; /* group ID */
afs_access_t caller_access; /* access rights for authenticated caller */
afs_access_t anon_access; /* access rights for unauthenticated caller */
umode_t mode; /* UNIX mode */
time_t mtime_client; /* last time client changed data */
time_t mtime_server; /* last time server changed data */
s32 lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */
};

Expand Down
2 changes: 2 additions & 0 deletions fs/afs/afs_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ enum AFS_FS_Operations {
FSGETVOLUMEINFO = 148, /* AFS Get information about a volume */
FSGETVOLUMESTATUS = 149, /* AFS Get volume status information */
FSGETROOTVOLUME = 151, /* AFS Get root volume name */
FSBULKSTATUS = 155, /* AFS Fetch multiple file statuses */
FSSETLOCK = 156, /* AFS Request a file lock */
FSEXTENDLOCK = 157, /* AFS Extend a file lock */
FSRELEASELOCK = 158, /* AFS Release a file lock */
FSLOOKUP = 161, /* AFS lookup file in directory */
FSINLINEBULKSTATUS = 65536, /* AFS Fetch multiple file statuses with inline errors */
FSFETCHDATA64 = 65537, /* AFS Fetch file data */
FSSTOREDATA64 = 65538, /* AFS Store file data */
FSGIVEUPALLCALLBACKS = 65539, /* AFS Give up all outstanding callbacks on a server */
Expand Down
8 changes: 4 additions & 4 deletions fs/afs/callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static void afs_break_one_callback(struct afs_server *server,
* allow the fileserver to break callback promises
*/
void afs_break_callbacks(struct afs_server *server, size_t count,
struct afs_callback callbacks[])
struct afs_callback_break *callbacks)
{
_enter("%p,%zu,", server, count);

Expand All @@ -199,9 +199,9 @@ void afs_break_callbacks(struct afs_server *server, size_t count,
callbacks->fid.vid,
callbacks->fid.vnode,
callbacks->fid.unique,
callbacks->version,
callbacks->expiry,
callbacks->type
callbacks->cb.version,
callbacks->cb.expiry,
callbacks->cb.type
);
afs_break_one_callback(server, &callbacks->fid);
}
Expand Down
12 changes: 6 additions & 6 deletions fs/afs/cmservice.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ static void SRXAFSCB_CallBack(struct work_struct *work)
*/
static int afs_deliver_cb_callback(struct afs_call *call)
{
struct afs_callback_break *cb;
struct sockaddr_rxrpc srx;
struct afs_callback *cb;
struct afs_server *server;
__be32 *bp;
int ret, loop;
Expand Down Expand Up @@ -218,7 +218,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)

_debug("unmarshall FID array");
call->request = kcalloc(call->count,
sizeof(struct afs_callback),
sizeof(struct afs_callback_break),
GFP_KERNEL);
if (!call->request)
return -ENOMEM;
Expand All @@ -229,7 +229,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
cb->fid.vid = ntohl(*bp++);
cb->fid.vnode = ntohl(*bp++);
cb->fid.unique = ntohl(*bp++);
cb->type = AFSCM_CB_UNTYPED;
cb->cb.type = AFSCM_CB_UNTYPED;
}

call->offset = 0;
Expand Down Expand Up @@ -260,9 +260,9 @@ static int afs_deliver_cb_callback(struct afs_call *call)
cb = call->request;
bp = call->buffer;
for (loop = call->count2; loop > 0; loop--, cb++) {
cb->version = ntohl(*bp++);
cb->expiry = ntohl(*bp++);
cb->type = ntohl(*bp++);
cb->cb.version = ntohl(*bp++);
cb->cb.expiry = ntohl(*bp++);
cb->cb.type = ntohl(*bp++);
}

call->offset = 0;
Expand Down
Loading

0 comments on commit 5cf9dd5

Please sign in to comment.