Skip to content

Commit

Permalink
Merge pull request #252 from shreyassiravara/nfs-pagecache-export
Browse files Browse the repository at this point in the history
Add & export a call to initialize the pagecache
  • Loading branch information
sahlberg committed Apr 29, 2018
2 parents 40a8f13 + 1fff770 commit 63ba842
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
6 changes: 6 additions & 0 deletions include/nfsc/libnfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ EXTERN int nfs_set_version(struct nfs_context *nfs, int version);
EXTERN void nfs_pagecache_invalidate(struct nfs_context *nfs,
struct nfsfh *nfsfh);

/*
* Initialize the pagecache
*/
EXTERN void nfs_pagecache_init(struct nfs_context *nfs,
struct nfsfh *nfsfh);

/*
* MOUNT THE EXPORT
*/
Expand Down
12 changes: 12 additions & 0 deletions lib/libnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ nfs_pagecache_get(struct nfs_pagecache *pagecache, uint64_t offset)
return e->buf;
}

void nfs_pagecache_init(struct nfs_context *nfs, struct nfsfh *nfsfh) {
/* init page cache */
if (nfs->rpc->pagecache) {
nfsfh->pagecache.num_entries = nfs->rpc->pagecache;
nfsfh->pagecache.ttl = nfs->rpc->pagecache_ttl;
nfsfh->pagecache.entries = malloc(sizeof(struct nfs_pagecache_entry) * nfsfh->pagecache.num_entries);
nfs_pagecache_invalidate(nfs, nfsfh);
RPC_LOG(nfs->rpc, 2, "init pagecache entries %d pagesize %d\n",
nfsfh->pagecache.num_entries, NFS_BLKSIZE);
}
}

void
nfs_set_auth(struct nfs_context *nfs, struct AUTH *auth)
{
Expand Down
13 changes: 3 additions & 10 deletions lib/nfs_v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -4917,20 +4917,13 @@ nfs3_open_cb(struct rpc_context *rpc, int status, void *command_data,
nfsfh->is_append = 1;
}

/* init the pagecache */
nfs_pagecache_init(nfs, nfsfh);

/* steal the filehandle */
nfsfh->fh = data->fh;
data->fh.val = NULL;

/* init page cache */
if (rpc->pagecache) {
nfsfh->pagecache.num_entries = rpc->pagecache;
nfsfh->pagecache.ttl = rpc->pagecache_ttl;
nfsfh->pagecache.entries = malloc(sizeof(struct nfs_pagecache_entry) * nfsfh->pagecache.num_entries);
nfs_pagecache_invalidate(nfs, nfsfh);
RPC_LOG(nfs->rpc, 2, "init pagecache entries %d pagesize %d\n",
nfsfh->pagecache.num_entries, NFS_BLKSIZE);
}

data->cb(0, nfs, nfsfh, data->private_data);
free_nfs_cb_data(data);
}
Expand Down

0 comments on commit 63ba842

Please sign in to comment.