Commit fe238e60 authored by Dave Wysochanski's avatar Dave Wysochanski Committed by Anna Schumaker

NFS: Save struct inode * inside nfs_commit_info to clarify usage of i_lock

Commit ea2cf228 created nfs_commit_info and saved &inode->i_lock inside
this NFS specific structure.  This obscures the usage of i_lock.
Instead, save struct inode * so later it's clear the spinlock taken is
i_lock.

Should be no functional change.
Signed-off-by: default avatarDave Wysochanski <dwysocha@redhat.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent ed3743a6
...@@ -278,7 +278,7 @@ static void nfs_direct_release_pages(struct page **pages, unsigned int npages) ...@@ -278,7 +278,7 @@ static void nfs_direct_release_pages(struct page **pages, unsigned int npages)
void nfs_init_cinfo_from_dreq(struct nfs_commit_info *cinfo, void nfs_init_cinfo_from_dreq(struct nfs_commit_info *cinfo,
struct nfs_direct_req *dreq) struct nfs_direct_req *dreq)
{ {
cinfo->lock = &dreq->inode->i_lock; cinfo->inode = dreq->inode;
cinfo->mds = &dreq->mds_cinfo; cinfo->mds = &dreq->mds_cinfo;
cinfo->ds = &dreq->ds_cinfo; cinfo->ds = &dreq->ds_cinfo;
cinfo->dreq = dreq; cinfo->dreq = dreq;
...@@ -635,13 +635,13 @@ nfs_direct_write_scan_commit_list(struct inode *inode, ...@@ -635,13 +635,13 @@ nfs_direct_write_scan_commit_list(struct inode *inode,
struct list_head *list, struct list_head *list,
struct nfs_commit_info *cinfo) struct nfs_commit_info *cinfo)
{ {
spin_lock(cinfo->lock); spin_lock(&cinfo->inode->i_lock);
#ifdef CONFIG_NFS_V4_1 #ifdef CONFIG_NFS_V4_1
if (cinfo->ds != NULL && cinfo->ds->nwritten != 0) if (cinfo->ds != NULL && cinfo->ds->nwritten != 0)
NFS_SERVER(inode)->pnfs_curr_ld->recover_commit_reqs(list, cinfo); NFS_SERVER(inode)->pnfs_curr_ld->recover_commit_reqs(list, cinfo);
#endif #endif
nfs_scan_commit_list(&cinfo->mds->list, list, cinfo, 0); nfs_scan_commit_list(&cinfo->mds->list, list, cinfo, 0);
spin_unlock(cinfo->lock); spin_unlock(&cinfo->inode->i_lock);
} }
static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq) static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
...@@ -676,13 +676,13 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq) ...@@ -676,13 +676,13 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
if (!nfs_pageio_add_request(&desc, req)) { if (!nfs_pageio_add_request(&desc, req)) {
nfs_list_remove_request(req); nfs_list_remove_request(req);
nfs_list_add_request(req, &failed); nfs_list_add_request(req, &failed);
spin_lock(cinfo.lock); spin_lock(&cinfo.inode->i_lock);
dreq->flags = 0; dreq->flags = 0;
if (desc.pg_error < 0) if (desc.pg_error < 0)
dreq->error = desc.pg_error; dreq->error = desc.pg_error;
else else
dreq->error = -EIO; dreq->error = -EIO;
spin_unlock(cinfo.lock); spin_unlock(&cinfo.inode->i_lock);
} }
nfs_release_request(req); nfs_release_request(req);
} }
......
...@@ -795,7 +795,7 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg, ...@@ -795,7 +795,7 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg,
buckets[i].direct_verf.committed = NFS_INVALID_STABLE_HOW; buckets[i].direct_verf.committed = NFS_INVALID_STABLE_HOW;
} }
spin_lock(cinfo->lock); spin_lock(&cinfo->inode->i_lock);
if (cinfo->ds->nbuckets >= size) if (cinfo->ds->nbuckets >= size)
goto out; goto out;
for (i = 0; i < cinfo->ds->nbuckets; i++) { for (i = 0; i < cinfo->ds->nbuckets; i++) {
...@@ -811,7 +811,7 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg, ...@@ -811,7 +811,7 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg,
swap(cinfo->ds->buckets, buckets); swap(cinfo->ds->buckets, buckets);
cinfo->ds->nbuckets = size; cinfo->ds->nbuckets = size;
out: out:
spin_unlock(cinfo->lock); spin_unlock(&cinfo->inode->i_lock);
kfree(buckets); kfree(buckets);
return 0; return 0;
} }
......
...@@ -745,7 +745,7 @@ ff_layout_alloc_commit_info(struct pnfs_layout_segment *lseg, ...@@ -745,7 +745,7 @@ ff_layout_alloc_commit_info(struct pnfs_layout_segment *lseg,
else { else {
int i; int i;
spin_lock(cinfo->lock); spin_lock(&cinfo->inode->i_lock);
if (cinfo->ds->nbuckets != 0) if (cinfo->ds->nbuckets != 0)
kfree(buckets); kfree(buckets);
else { else {
...@@ -759,7 +759,7 @@ ff_layout_alloc_commit_info(struct pnfs_layout_segment *lseg, ...@@ -759,7 +759,7 @@ ff_layout_alloc_commit_info(struct pnfs_layout_segment *lseg,
NFS_INVALID_STABLE_HOW; NFS_INVALID_STABLE_HOW;
} }
} }
spin_unlock(cinfo->lock); spin_unlock(&cinfo->inode->i_lock);
return 0; return 0;
} }
} }
......
...@@ -61,7 +61,7 @@ EXPORT_SYMBOL_GPL(pnfs_generic_commit_release); ...@@ -61,7 +61,7 @@ EXPORT_SYMBOL_GPL(pnfs_generic_commit_release);
/* The generic layer is about to remove the req from the commit list. /* The generic layer is about to remove the req from the commit list.
* If this will make the bucket empty, it will need to put the lseg reference. * If this will make the bucket empty, it will need to put the lseg reference.
* Note this must be called holding the inode (/cinfo) lock * Note this must be called holding i_lock
*/ */
void void
pnfs_generic_clear_request_commit(struct nfs_page *req, pnfs_generic_clear_request_commit(struct nfs_page *req,
...@@ -98,7 +98,7 @@ pnfs_generic_transfer_commit_list(struct list_head *src, struct list_head *dst, ...@@ -98,7 +98,7 @@ pnfs_generic_transfer_commit_list(struct list_head *src, struct list_head *dst,
if (!nfs_lock_request(req)) if (!nfs_lock_request(req))
continue; continue;
kref_get(&req->wb_kref); kref_get(&req->wb_kref);
if (cond_resched_lock(cinfo->lock)) if (cond_resched_lock(&cinfo->inode->i_lock))
list_safe_reset_next(req, tmp, wb_list); list_safe_reset_next(req, tmp, wb_list);
nfs_request_remove_commit_list(req, cinfo); nfs_request_remove_commit_list(req, cinfo);
clear_bit(PG_COMMIT_TO_DS, &req->wb_flags); clear_bit(PG_COMMIT_TO_DS, &req->wb_flags);
...@@ -119,7 +119,7 @@ pnfs_generic_scan_ds_commit_list(struct pnfs_commit_bucket *bucket, ...@@ -119,7 +119,7 @@ pnfs_generic_scan_ds_commit_list(struct pnfs_commit_bucket *bucket,
struct list_head *dst = &bucket->committing; struct list_head *dst = &bucket->committing;
int ret; int ret;
lockdep_assert_held(cinfo->lock); lockdep_assert_held(&cinfo->inode->i_lock);
ret = pnfs_generic_transfer_commit_list(src, dst, cinfo, max); ret = pnfs_generic_transfer_commit_list(src, dst, cinfo, max);
if (ret) { if (ret) {
cinfo->ds->nwritten -= ret; cinfo->ds->nwritten -= ret;
...@@ -142,7 +142,7 @@ int pnfs_generic_scan_commit_lists(struct nfs_commit_info *cinfo, ...@@ -142,7 +142,7 @@ int pnfs_generic_scan_commit_lists(struct nfs_commit_info *cinfo,
{ {
int i, rv = 0, cnt; int i, rv = 0, cnt;
lockdep_assert_held(cinfo->lock); lockdep_assert_held(&cinfo->inode->i_lock);
for (i = 0; i < cinfo->ds->nbuckets && max != 0; i++) { for (i = 0; i < cinfo->ds->nbuckets && max != 0; i++) {
cnt = pnfs_generic_scan_ds_commit_list(&cinfo->ds->buckets[i], cnt = pnfs_generic_scan_ds_commit_list(&cinfo->ds->buckets[i],
cinfo, max); cinfo, max);
...@@ -161,16 +161,16 @@ void pnfs_generic_recover_commit_reqs(struct list_head *dst, ...@@ -161,16 +161,16 @@ void pnfs_generic_recover_commit_reqs(struct list_head *dst,
struct pnfs_layout_segment *freeme; struct pnfs_layout_segment *freeme;
int i; int i;
lockdep_assert_held(cinfo->lock); lockdep_assert_held(&cinfo->inode->i_lock);
restart: restart:
for (i = 0, b = cinfo->ds->buckets; i < cinfo->ds->nbuckets; i++, b++) { for (i = 0, b = cinfo->ds->buckets; i < cinfo->ds->nbuckets; i++, b++) {
if (pnfs_generic_transfer_commit_list(&b->written, dst, if (pnfs_generic_transfer_commit_list(&b->written, dst,
cinfo, 0)) { cinfo, 0)) {
freeme = b->wlseg; freeme = b->wlseg;
b->wlseg = NULL; b->wlseg = NULL;
spin_unlock(cinfo->lock); spin_unlock(&cinfo->inode->i_lock);
pnfs_put_lseg(freeme); pnfs_put_lseg(freeme);
spin_lock(cinfo->lock); spin_lock(&cinfo->inode->i_lock);
goto restart; goto restart;
} }
} }
...@@ -186,7 +186,7 @@ static void pnfs_generic_retry_commit(struct nfs_commit_info *cinfo, int idx) ...@@ -186,7 +186,7 @@ static void pnfs_generic_retry_commit(struct nfs_commit_info *cinfo, int idx)
LIST_HEAD(pages); LIST_HEAD(pages);
int i; int i;
spin_lock(cinfo->lock); spin_lock(&cinfo->inode->i_lock);
for (i = idx; i < fl_cinfo->nbuckets; i++) { for (i = idx; i < fl_cinfo->nbuckets; i++) {
bucket = &fl_cinfo->buckets[i]; bucket = &fl_cinfo->buckets[i];
if (list_empty(&bucket->committing)) if (list_empty(&bucket->committing))
...@@ -194,12 +194,12 @@ static void pnfs_generic_retry_commit(struct nfs_commit_info *cinfo, int idx) ...@@ -194,12 +194,12 @@ static void pnfs_generic_retry_commit(struct nfs_commit_info *cinfo, int idx)
freeme = bucket->clseg; freeme = bucket->clseg;
bucket->clseg = NULL; bucket->clseg = NULL;
list_splice_init(&bucket->committing, &pages); list_splice_init(&bucket->committing, &pages);
spin_unlock(cinfo->lock); spin_unlock(&cinfo->inode->i_lock);
nfs_retry_commit(&pages, freeme, cinfo, i); nfs_retry_commit(&pages, freeme, cinfo, i);
pnfs_put_lseg(freeme); pnfs_put_lseg(freeme);
spin_lock(cinfo->lock); spin_lock(&cinfo->inode->i_lock);
} }
spin_unlock(cinfo->lock); spin_unlock(&cinfo->inode->i_lock);
} }
static unsigned int static unsigned int
...@@ -238,11 +238,11 @@ void pnfs_fetch_commit_bucket_list(struct list_head *pages, ...@@ -238,11 +238,11 @@ void pnfs_fetch_commit_bucket_list(struct list_head *pages,
struct pnfs_commit_bucket *bucket; struct pnfs_commit_bucket *bucket;
bucket = &cinfo->ds->buckets[data->ds_commit_index]; bucket = &cinfo->ds->buckets[data->ds_commit_index];
spin_lock(cinfo->lock); spin_lock(&cinfo->inode->i_lock);
list_splice_init(&bucket->committing, pages); list_splice_init(&bucket->committing, pages);
data->lseg = bucket->clseg; data->lseg = bucket->clseg;
bucket->clseg = NULL; bucket->clseg = NULL;
spin_unlock(cinfo->lock); spin_unlock(&cinfo->inode->i_lock);
} }
...@@ -874,12 +874,12 @@ pnfs_layout_mark_request_commit(struct nfs_page *req, ...@@ -874,12 +874,12 @@ pnfs_layout_mark_request_commit(struct nfs_page *req,
struct list_head *list; struct list_head *list;
struct pnfs_commit_bucket *buckets; struct pnfs_commit_bucket *buckets;
spin_lock(cinfo->lock); spin_lock(&cinfo->inode->i_lock);
buckets = cinfo->ds->buckets; buckets = cinfo->ds->buckets;
list = &buckets[ds_commit_idx].written; list = &buckets[ds_commit_idx].written;
if (list_empty(list)) { if (list_empty(list)) {
if (!pnfs_is_valid_lseg(lseg)) { if (!pnfs_is_valid_lseg(lseg)) {
spin_unlock(cinfo->lock); spin_unlock(&cinfo->inode->i_lock);
cinfo->completion_ops->resched_write(cinfo, req); cinfo->completion_ops->resched_write(cinfo, req);
return; return;
} }
...@@ -896,7 +896,7 @@ pnfs_layout_mark_request_commit(struct nfs_page *req, ...@@ -896,7 +896,7 @@ pnfs_layout_mark_request_commit(struct nfs_page *req,
cinfo->ds->nwritten++; cinfo->ds->nwritten++;
nfs_request_add_commit_list_locked(req, list, cinfo); nfs_request_add_commit_list_locked(req, list, cinfo);
spin_unlock(cinfo->lock); spin_unlock(&cinfo->inode->i_lock);
nfs_mark_page_unstable(req->wb_page, cinfo); nfs_mark_page_unstable(req->wb_page, cinfo);
} }
EXPORT_SYMBOL_GPL(pnfs_layout_mark_request_commit); EXPORT_SYMBOL_GPL(pnfs_layout_mark_request_commit);
......
...@@ -804,7 +804,7 @@ nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi, ...@@ -804,7 +804,7 @@ nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
* number of outstanding requests requiring a commit as well as * number of outstanding requests requiring a commit as well as
* the MM page stats. * the MM page stats.
* *
* The caller must hold the cinfo->lock, and the nfs_page lock. * The caller must hold cinfo->inode->i_lock, and the nfs_page lock.
*/ */
void void
nfs_request_add_commit_list_locked(struct nfs_page *req, struct list_head *dst, nfs_request_add_commit_list_locked(struct nfs_page *req, struct list_head *dst,
...@@ -832,9 +832,9 @@ EXPORT_SYMBOL_GPL(nfs_request_add_commit_list_locked); ...@@ -832,9 +832,9 @@ EXPORT_SYMBOL_GPL(nfs_request_add_commit_list_locked);
void void
nfs_request_add_commit_list(struct nfs_page *req, struct nfs_commit_info *cinfo) nfs_request_add_commit_list(struct nfs_page *req, struct nfs_commit_info *cinfo)
{ {
spin_lock(cinfo->lock); spin_lock(&cinfo->inode->i_lock);
nfs_request_add_commit_list_locked(req, &cinfo->mds->list, cinfo); nfs_request_add_commit_list_locked(req, &cinfo->mds->list, cinfo);
spin_unlock(cinfo->lock); spin_unlock(&cinfo->inode->i_lock);
nfs_mark_page_unstable(req->wb_page, cinfo); nfs_mark_page_unstable(req->wb_page, cinfo);
} }
EXPORT_SYMBOL_GPL(nfs_request_add_commit_list); EXPORT_SYMBOL_GPL(nfs_request_add_commit_list);
...@@ -864,7 +864,7 @@ EXPORT_SYMBOL_GPL(nfs_request_remove_commit_list); ...@@ -864,7 +864,7 @@ EXPORT_SYMBOL_GPL(nfs_request_remove_commit_list);
static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo, static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo,
struct inode *inode) struct inode *inode)
{ {
cinfo->lock = &inode->i_lock; cinfo->inode = inode;
cinfo->mds = &NFS_I(inode)->commit_info; cinfo->mds = &NFS_I(inode)->commit_info;
cinfo->ds = pnfs_get_ds_info(inode); cinfo->ds = pnfs_get_ds_info(inode);
cinfo->dreq = NULL; cinfo->dreq = NULL;
...@@ -967,7 +967,7 @@ nfs_reqs_to_commit(struct nfs_commit_info *cinfo) ...@@ -967,7 +967,7 @@ nfs_reqs_to_commit(struct nfs_commit_info *cinfo)
return cinfo->mds->ncommit; return cinfo->mds->ncommit;
} }
/* cinfo->lock held by caller */ /* cinfo->inode->i_lock held by caller */
int int
nfs_scan_commit_list(struct list_head *src, struct list_head *dst, nfs_scan_commit_list(struct list_head *src, struct list_head *dst,
struct nfs_commit_info *cinfo, int max) struct nfs_commit_info *cinfo, int max)
...@@ -979,7 +979,7 @@ nfs_scan_commit_list(struct list_head *src, struct list_head *dst, ...@@ -979,7 +979,7 @@ nfs_scan_commit_list(struct list_head *src, struct list_head *dst,
if (!nfs_lock_request(req)) if (!nfs_lock_request(req))
continue; continue;
kref_get(&req->wb_kref); kref_get(&req->wb_kref);
if (cond_resched_lock(cinfo->lock)) if (cond_resched_lock(&cinfo->inode->i_lock))
list_safe_reset_next(req, tmp, wb_list); list_safe_reset_next(req, tmp, wb_list);
nfs_request_remove_commit_list(req, cinfo); nfs_request_remove_commit_list(req, cinfo);
nfs_list_add_request(req, dst); nfs_list_add_request(req, dst);
...@@ -1005,7 +1005,7 @@ nfs_scan_commit(struct inode *inode, struct list_head *dst, ...@@ -1005,7 +1005,7 @@ nfs_scan_commit(struct inode *inode, struct list_head *dst,
{ {
int ret = 0; int ret = 0;
spin_lock(cinfo->lock); spin_lock(&cinfo->inode->i_lock);
if (cinfo->mds->ncommit > 0) { if (cinfo->mds->ncommit > 0) {
const int max = INT_MAX; const int max = INT_MAX;
...@@ -1013,7 +1013,7 @@ nfs_scan_commit(struct inode *inode, struct list_head *dst, ...@@ -1013,7 +1013,7 @@ nfs_scan_commit(struct inode *inode, struct list_head *dst,
cinfo, max); cinfo, max);
ret += pnfs_scan_commit_lists(inode, cinfo, max - ret); ret += pnfs_scan_commit_lists(inode, cinfo, max - ret);
} }
spin_unlock(cinfo->lock); spin_unlock(&cinfo->inode->i_lock);
return ret; return ret;
} }
......
...@@ -1431,7 +1431,7 @@ struct nfs_commit_completion_ops { ...@@ -1431,7 +1431,7 @@ struct nfs_commit_completion_ops {
}; };
struct nfs_commit_info { struct nfs_commit_info {
spinlock_t *lock; /* inode->i_lock */ struct inode *inode; /* Needed for inode->i_lock */
struct nfs_mds_commit_info *mds; struct nfs_mds_commit_info *mds;
struct pnfs_ds_commit_info *ds; struct pnfs_ds_commit_info *ds;
struct nfs_direct_req *dreq; /* O_DIRECT request */ struct nfs_direct_req *dreq; /* O_DIRECT request */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment