Skip to content

Commit

Permalink
NFS: Use an atomic_long_t to count the number of commits
Browse files Browse the repository at this point in the history
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
trondmypd committed Aug 15, 2017
1 parent a6b6d5b commit 5cb953d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ static void init_once(void *foo)
INIT_LIST_HEAD(&nfsi->access_cache_inode_lru);
INIT_LIST_HEAD(&nfsi->commit_info.list);
atomic_long_set(&nfsi->nrequests, 0);
nfsi->commit_info.ncommit = 0;
atomic_long_set(&nfsi->commit_info.ncommit, 0);
atomic_set(&nfsi->commit_info.rpcs_out, 0);
init_rwsem(&nfsi->rmdir_sem);
mutex_init(&nfsi->commit_mutex);
Expand Down
12 changes: 7 additions & 5 deletions fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ nfs_request_add_commit_list_locked(struct nfs_page *req, struct list_head *dst,
{
set_bit(PG_CLEAN, &req->wb_flags);
nfs_list_add_request(req, dst);
cinfo->mds->ncommit++;
atomic_long_inc(&cinfo->mds->ncommit);
}
EXPORT_SYMBOL_GPL(nfs_request_add_commit_list_locked);

Expand Down Expand Up @@ -903,7 +903,7 @@ nfs_request_remove_commit_list(struct nfs_page *req,
if (!test_and_clear_bit(PG_CLEAN, &(req)->wb_flags))
return;
nfs_list_remove_request(req);
cinfo->mds->ncommit--;
atomic_long_dec(&cinfo->mds->ncommit);
}
EXPORT_SYMBOL_GPL(nfs_request_remove_commit_list);

Expand Down Expand Up @@ -1017,7 +1017,7 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr)
unsigned long
nfs_reqs_to_commit(struct nfs_commit_info *cinfo)
{
return cinfo->mds->ncommit;
return atomic_long_read(&cinfo->mds->ncommit);
}

/* NFS_I(cinfo->inode)->commit_mutex held by caller */
Expand Down Expand Up @@ -1057,8 +1057,10 @@ nfs_scan_commit(struct inode *inode, struct list_head *dst,
{
int ret = 0;

if (!atomic_long_read(&cinfo->mds->ncommit))
return 0;
mutex_lock(&NFS_I(cinfo->inode)->commit_mutex);
if (cinfo->mds->ncommit > 0) {
if (atomic_long_read(&cinfo->mds->ncommit) > 0) {
const int max = INT_MAX;

ret = nfs_scan_commit_list(&cinfo->mds->list, dst,
Expand Down Expand Up @@ -1890,7 +1892,7 @@ int nfs_write_inode(struct inode *inode, struct writeback_control *wbc)
int ret = 0;

/* no commits means nothing needs to be done */
if (!nfsi->commit_info.ncommit)
if (!atomic_long_read(&nfsi->commit_info.ncommit))
return ret;

if (wbc->sync_mode == WB_SYNC_NONE) {
Expand Down
2 changes: 1 addition & 1 deletion include/linux/nfs_xdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ struct nfs_pgio_header {

struct nfs_mds_commit_info {
atomic_t rpcs_out;
unsigned long ncommit;
atomic_long_t ncommit;
struct list_head list;
};

Expand Down

0 comments on commit 5cb953d

Please sign in to comment.