aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Wysochanski <dwysocha@redhat.com>2016-04-01 13:45:09 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2016-05-09 09:05:40 -0400
commitfe238e601d2519f259103ab65caea3b077ed7b39 (patch)
tree88b50933a24b69ccae24bb52f2f9bfb6b1dce2e7
parented3743a6d4f309f5278c87a69e3125382b78455c (diff)
NFS: Save struct inode * inside nfs_commit_info to clarify usage of i_lock
Commit ea2cf22 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: Dave Wysochanski <dwysocha@redhat.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r--fs/nfs/direct.c10
-rw-r--r--fs/nfs/filelayout/filelayout.c4
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c4
-rw-r--r--fs/nfs/pnfs_nfs.c32
-rw-r--r--fs/nfs/write.c16
-rw-r--r--include/linux/nfs_xdr.h2
6 files changed, 34 insertions, 34 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index f79d98ae4c10..7f03163b5364 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -278,7 +278,7 @@ static void nfs_direct_release_pages(struct page **pages, unsigned int npages)
278void nfs_init_cinfo_from_dreq(struct nfs_commit_info *cinfo, 278void nfs_init_cinfo_from_dreq(struct nfs_commit_info *cinfo,
279 struct nfs_direct_req *dreq) 279 struct nfs_direct_req *dreq)
280{ 280{
281 cinfo->lock = &dreq->inode->i_lock; 281 cinfo->inode = dreq->inode;
282 cinfo->mds = &dreq->mds_cinfo; 282 cinfo->mds = &dreq->mds_cinfo;
283 cinfo->ds = &dreq->ds_cinfo; 283 cinfo->ds = &dreq->ds_cinfo;
284 cinfo->dreq = dreq; 284 cinfo->dreq = dreq;
@@ -635,13 +635,13 @@ nfs_direct_write_scan_commit_list(struct inode *inode,
635 struct list_head *list, 635 struct list_head *list,
636 struct nfs_commit_info *cinfo) 636 struct nfs_commit_info *cinfo)
637{ 637{
638 spin_lock(cinfo->lock); 638 spin_lock(&cinfo->inode->i_lock);
639#ifdef CONFIG_NFS_V4_1 639#ifdef CONFIG_NFS_V4_1
640 if (cinfo->ds != NULL && cinfo->ds->nwritten != 0) 640 if (cinfo->ds != NULL && cinfo->ds->nwritten != 0)
641 NFS_SERVER(inode)->pnfs_curr_ld->recover_commit_reqs(list, cinfo); 641 NFS_SERVER(inode)->pnfs_curr_ld->recover_commit_reqs(list, cinfo);
642#endif 642#endif
643 nfs_scan_commit_list(&cinfo->mds->list, list, cinfo, 0); 643 nfs_scan_commit_list(&cinfo->mds->list, list, cinfo, 0);
644 spin_unlock(cinfo->lock); 644 spin_unlock(&cinfo->inode->i_lock);
645} 645}
646 646
647static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq) 647static 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 if (!nfs_pageio_add_request(&desc, req)) { 676 if (!nfs_pageio_add_request(&desc, req)) {
677 nfs_list_remove_request(req); 677 nfs_list_remove_request(req);
678 nfs_list_add_request(req, &failed); 678 nfs_list_add_request(req, &failed);
679 spin_lock(cinfo.lock); 679 spin_lock(&cinfo.inode->i_lock);
680 dreq->flags = 0; 680 dreq->flags = 0;
681 if (desc.pg_error < 0) 681 if (desc.pg_error < 0)
682 dreq->error = desc.pg_error; 682 dreq->error = desc.pg_error;
683 else 683 else
684 dreq->error = -EIO; 684 dreq->error = -EIO;
685 spin_unlock(cinfo.lock); 685 spin_unlock(&cinfo.inode->i_lock);
686 } 686 }
687 nfs_release_request(req); 687 nfs_release_request(req);
688 } 688 }
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index 3384dc8e6683..3e50057eeadf 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -795,7 +795,7 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg,
795 buckets[i].direct_verf.committed = NFS_INVALID_STABLE_HOW; 795 buckets[i].direct_verf.committed = NFS_INVALID_STABLE_HOW;
796 } 796 }
797 797
798 spin_lock(cinfo->lock); 798 spin_lock(&cinfo->inode->i_lock);
799 if (cinfo->ds->nbuckets >= size) 799 if (cinfo->ds->nbuckets >= size)
800 goto out; 800 goto out;
801 for (i = 0; i < cinfo->ds->nbuckets; i++) { 801 for (i = 0; i < cinfo->ds->nbuckets; i++) {
@@ -811,7 +811,7 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg,
811 swap(cinfo->ds->buckets, buckets); 811 swap(cinfo->ds->buckets, buckets);
812 cinfo->ds->nbuckets = size; 812 cinfo->ds->nbuckets = size;
813out: 813out:
814 spin_unlock(cinfo->lock); 814 spin_unlock(&cinfo->inode->i_lock);
815 kfree(buckets); 815 kfree(buckets);
816 return 0; 816 return 0;
817} 817}
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 0cb1abd535e3..3b398f7b4637 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -745,7 +745,7 @@ ff_layout_alloc_commit_info(struct pnfs_layout_segment *lseg,
745 else { 745 else {
746 int i; 746 int i;
747 747
748 spin_lock(cinfo->lock); 748 spin_lock(&cinfo->inode->i_lock);
749 if (cinfo->ds->nbuckets != 0) 749 if (cinfo->ds->nbuckets != 0)
750 kfree(buckets); 750 kfree(buckets);
751 else { 751 else {
@@ -759,7 +759,7 @@ ff_layout_alloc_commit_info(struct pnfs_layout_segment *lseg,
759 NFS_INVALID_STABLE_HOW; 759 NFS_INVALID_STABLE_HOW;
760 } 760 }
761 } 761 }
762 spin_unlock(cinfo->lock); 762 spin_unlock(&cinfo->inode->i_lock);
763 return 0; 763 return 0;
764 } 764 }
765} 765}
diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
index 4aaed890048f..d2a7c9f7aa94 100644
--- a/fs/nfs/pnfs_nfs.c
+++ b/fs/nfs/pnfs_nfs.c
@@ -61,7 +61,7 @@ EXPORT_SYMBOL_GPL(pnfs_generic_commit_release);
61 61
62/* The generic layer is about to remove the req from the commit list. 62/* The generic layer is about to remove the req from the commit list.
63 * If this will make the bucket empty, it will need to put the lseg reference. 63 * If this will make the bucket empty, it will need to put the lseg reference.
64 * Note this must be called holding the inode (/cinfo) lock 64 * Note this must be called holding i_lock
65 */ 65 */
66void 66void
67pnfs_generic_clear_request_commit(struct nfs_page *req, 67pnfs_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 if (!nfs_lock_request(req)) 98 if (!nfs_lock_request(req))
99 continue; 99 continue;
100 kref_get(&req->wb_kref); 100 kref_get(&req->wb_kref);
101 if (cond_resched_lock(cinfo->lock)) 101 if (cond_resched_lock(&cinfo->inode->i_lock))
102 list_safe_reset_next(req, tmp, wb_list); 102 list_safe_reset_next(req, tmp, wb_list);
103 nfs_request_remove_commit_list(req, cinfo); 103 nfs_request_remove_commit_list(req, cinfo);
104 clear_bit(PG_COMMIT_TO_DS, &req->wb_flags); 104 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 struct list_head *dst = &bucket->committing; 119 struct list_head *dst = &bucket->committing;
120 int ret; 120 int ret;
121 121
122 lockdep_assert_held(cinfo->lock); 122 lockdep_assert_held(&cinfo->inode->i_lock);
123 ret = pnfs_generic_transfer_commit_list(src, dst, cinfo, max); 123 ret = pnfs_generic_transfer_commit_list(src, dst, cinfo, max);
124 if (ret) { 124 if (ret) {
125 cinfo->ds->nwritten -= ret; 125 cinfo->ds->nwritten -= ret;
@@ -142,7 +142,7 @@ int pnfs_generic_scan_commit_lists(struct nfs_commit_info *cinfo,
142{ 142{
143 int i, rv = 0, cnt; 143 int i, rv = 0, cnt;
144 144
145 lockdep_assert_held(cinfo->lock); 145 lockdep_assert_held(&cinfo->inode->i_lock);
146 for (i = 0; i < cinfo->ds->nbuckets && max != 0; i++) { 146 for (i = 0; i < cinfo->ds->nbuckets && max != 0; i++) {
147 cnt = pnfs_generic_scan_ds_commit_list(&cinfo->ds->buckets[i], 147 cnt = pnfs_generic_scan_ds_commit_list(&cinfo->ds->buckets[i],
148 cinfo, max); 148 cinfo, max);
@@ -161,16 +161,16 @@ void pnfs_generic_recover_commit_reqs(struct list_head *dst,
161 struct pnfs_layout_segment *freeme; 161 struct pnfs_layout_segment *freeme;
162 int i; 162 int i;
163 163
164 lockdep_assert_held(cinfo->lock); 164 lockdep_assert_held(&cinfo->inode->i_lock);
165restart: 165restart:
166 for (i = 0, b = cinfo->ds->buckets; i < cinfo->ds->nbuckets; i++, b++) { 166 for (i = 0, b = cinfo->ds->buckets; i < cinfo->ds->nbuckets; i++, b++) {
167 if (pnfs_generic_transfer_commit_list(&b->written, dst, 167 if (pnfs_generic_transfer_commit_list(&b->written, dst,
168 cinfo, 0)) { 168 cinfo, 0)) {
169 freeme = b->wlseg; 169 freeme = b->wlseg;
170 b->wlseg = NULL; 170 b->wlseg = NULL;
171 spin_unlock(cinfo->lock); 171 spin_unlock(&cinfo->inode->i_lock);
172 pnfs_put_lseg(freeme); 172 pnfs_put_lseg(freeme);
173 spin_lock(cinfo->lock); 173 spin_lock(&cinfo->inode->i_lock);
174 goto restart; 174 goto restart;
175 } 175 }
176 } 176 }
@@ -186,7 +186,7 @@ static void pnfs_generic_retry_commit(struct nfs_commit_info *cinfo, int idx)
186 LIST_HEAD(pages); 186 LIST_HEAD(pages);
187 int i; 187 int i;
188 188
189 spin_lock(cinfo->lock); 189 spin_lock(&cinfo->inode->i_lock);
190 for (i = idx; i < fl_cinfo->nbuckets; i++) { 190 for (i = idx; i < fl_cinfo->nbuckets; i++) {
191 bucket = &fl_cinfo->buckets[i]; 191 bucket = &fl_cinfo->buckets[i];
192 if (list_empty(&bucket->committing)) 192 if (list_empty(&bucket->committing))
@@ -194,12 +194,12 @@ static void pnfs_generic_retry_commit(struct nfs_commit_info *cinfo, int idx)
194 freeme = bucket->clseg; 194 freeme = bucket->clseg;
195 bucket->clseg = NULL; 195 bucket->clseg = NULL;
196 list_splice_init(&bucket->committing, &pages); 196 list_splice_init(&bucket->committing, &pages);
197 spin_unlock(cinfo->lock); 197 spin_unlock(&cinfo->inode->i_lock);
198 nfs_retry_commit(&pages, freeme, cinfo, i); 198 nfs_retry_commit(&pages, freeme, cinfo, i);
199 pnfs_put_lseg(freeme); 199 pnfs_put_lseg(freeme);
200 spin_lock(cinfo->lock); 200 spin_lock(&cinfo->inode->i_lock);
201 } 201 }
202 spin_unlock(cinfo->lock); 202 spin_unlock(&cinfo->inode->i_lock);
203} 203}
204 204
205static unsigned int 205static unsigned int
@@ -238,11 +238,11 @@ void pnfs_fetch_commit_bucket_list(struct list_head *pages,
238 struct pnfs_commit_bucket *bucket; 238 struct pnfs_commit_bucket *bucket;
239 239
240 bucket = &cinfo->ds->buckets[data->ds_commit_index]; 240 bucket = &cinfo->ds->buckets[data->ds_commit_index];
241 spin_lock(cinfo->lock); 241 spin_lock(&cinfo->inode->i_lock);
242 list_splice_init(&bucket->committing, pages); 242 list_splice_init(&bucket->committing, pages);
243 data->lseg = bucket->clseg; 243 data->lseg = bucket->clseg;
244 bucket->clseg = NULL; 244 bucket->clseg = NULL;
245 spin_unlock(cinfo->lock); 245 spin_unlock(&cinfo->inode->i_lock);
246 246
247} 247}
248 248
@@ -874,12 +874,12 @@ pnfs_layout_mark_request_commit(struct nfs_page *req,
874 struct list_head *list; 874 struct list_head *list;
875 struct pnfs_commit_bucket *buckets; 875 struct pnfs_commit_bucket *buckets;
876 876
877 spin_lock(cinfo->lock); 877 spin_lock(&cinfo->inode->i_lock);
878 buckets = cinfo->ds->buckets; 878 buckets = cinfo->ds->buckets;
879 list = &buckets[ds_commit_idx].written; 879 list = &buckets[ds_commit_idx].written;
880 if (list_empty(list)) { 880 if (list_empty(list)) {
881 if (!pnfs_is_valid_lseg(lseg)) { 881 if (!pnfs_is_valid_lseg(lseg)) {
882 spin_unlock(cinfo->lock); 882 spin_unlock(&cinfo->inode->i_lock);
883 cinfo->completion_ops->resched_write(cinfo, req); 883 cinfo->completion_ops->resched_write(cinfo, req);
884 return; 884 return;
885 } 885 }
@@ -896,7 +896,7 @@ pnfs_layout_mark_request_commit(struct nfs_page *req,
896 cinfo->ds->nwritten++; 896 cinfo->ds->nwritten++;
897 897
898 nfs_request_add_commit_list_locked(req, list, cinfo); 898 nfs_request_add_commit_list_locked(req, list, cinfo);
899 spin_unlock(cinfo->lock); 899 spin_unlock(&cinfo->inode->i_lock);
900 nfs_mark_page_unstable(req->wb_page, cinfo); 900 nfs_mark_page_unstable(req->wb_page, cinfo);
901} 901}
902EXPORT_SYMBOL_GPL(pnfs_layout_mark_request_commit); 902EXPORT_SYMBOL_GPL(pnfs_layout_mark_request_commit);
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 5f4fd53e5764..9283a96b9fb8 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -804,7 +804,7 @@ nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
804 * number of outstanding requests requiring a commit as well as 804 * number of outstanding requests requiring a commit as well as
805 * the MM page stats. 805 * the MM page stats.
806 * 806 *
807 * The caller must hold the cinfo->lock, and the nfs_page lock. 807 * The caller must hold cinfo->inode->i_lock, and the nfs_page lock.
808 */ 808 */
809void 809void
810nfs_request_add_commit_list_locked(struct nfs_page *req, struct list_head *dst, 810nfs_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);
832void 832void
833nfs_request_add_commit_list(struct nfs_page *req, struct nfs_commit_info *cinfo) 833nfs_request_add_commit_list(struct nfs_page *req, struct nfs_commit_info *cinfo)
834{ 834{
835 spin_lock(cinfo->lock); 835 spin_lock(&cinfo->inode->i_lock);
836 nfs_request_add_commit_list_locked(req, &cinfo->mds->list, cinfo); 836 nfs_request_add_commit_list_locked(req, &cinfo->mds->list, cinfo);
837 spin_unlock(cinfo->lock); 837 spin_unlock(&cinfo->inode->i_lock);
838 nfs_mark_page_unstable(req->wb_page, cinfo); 838 nfs_mark_page_unstable(req->wb_page, cinfo);
839} 839}
840EXPORT_SYMBOL_GPL(nfs_request_add_commit_list); 840EXPORT_SYMBOL_GPL(nfs_request_add_commit_list);
@@ -864,7 +864,7 @@ EXPORT_SYMBOL_GPL(nfs_request_remove_commit_list);
864static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo, 864static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo,
865 struct inode *inode) 865 struct inode *inode)
866{ 866{
867 cinfo->lock = &inode->i_lock; 867 cinfo->inode = inode;
868 cinfo->mds = &NFS_I(inode)->commit_info; 868 cinfo->mds = &NFS_I(inode)->commit_info;
869 cinfo->ds = pnfs_get_ds_info(inode); 869 cinfo->ds = pnfs_get_ds_info(inode);
870 cinfo->dreq = NULL; 870 cinfo->dreq = NULL;
@@ -967,7 +967,7 @@ nfs_reqs_to_commit(struct nfs_commit_info *cinfo)
967 return cinfo->mds->ncommit; 967 return cinfo->mds->ncommit;
968} 968}
969 969
970/* cinfo->lock held by caller */ 970/* cinfo->inode->i_lock held by caller */
971int 971int
972nfs_scan_commit_list(struct list_head *src, struct list_head *dst, 972nfs_scan_commit_list(struct list_head *src, struct list_head *dst,
973 struct nfs_commit_info *cinfo, int max) 973 struct nfs_commit_info *cinfo, int max)
@@ -979,7 +979,7 @@ nfs_scan_commit_list(struct list_head *src, struct list_head *dst,
979 if (!nfs_lock_request(req)) 979 if (!nfs_lock_request(req))
980 continue; 980 continue;
981 kref_get(&req->wb_kref); 981 kref_get(&req->wb_kref);
982 if (cond_resched_lock(cinfo->lock)) 982 if (cond_resched_lock(&cinfo->inode->i_lock))
983 list_safe_reset_next(req, tmp, wb_list); 983 list_safe_reset_next(req, tmp, wb_list);
984 nfs_request_remove_commit_list(req, cinfo); 984 nfs_request_remove_commit_list(req, cinfo);
985 nfs_list_add_request(req, dst); 985 nfs_list_add_request(req, dst);
@@ -1005,7 +1005,7 @@ nfs_scan_commit(struct inode *inode, struct list_head *dst,
1005{ 1005{
1006 int ret = 0; 1006 int ret = 0;
1007 1007
1008 spin_lock(cinfo->lock); 1008 spin_lock(&cinfo->inode->i_lock);
1009 if (cinfo->mds->ncommit > 0) { 1009 if (cinfo->mds->ncommit > 0) {
1010 const int max = INT_MAX; 1010 const int max = INT_MAX;
1011 1011
@@ -1013,7 +1013,7 @@ nfs_scan_commit(struct inode *inode, struct list_head *dst,
1013 cinfo, max); 1013 cinfo, max);
1014 ret += pnfs_scan_commit_lists(inode, cinfo, max - ret); 1014 ret += pnfs_scan_commit_lists(inode, cinfo, max - ret);
1015 } 1015 }
1016 spin_unlock(cinfo->lock); 1016 spin_unlock(&cinfo->inode->i_lock);
1017 return ret; 1017 return ret;
1018} 1018}
1019 1019
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index d320906cf13e..cb9982d8f38f 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1431,7 +1431,7 @@ struct nfs_commit_completion_ops {
1431}; 1431};
1432 1432
1433struct nfs_commit_info { 1433struct nfs_commit_info {
1434 spinlock_t *lock; /* inode->i_lock */ 1434 struct inode *inode; /* Needed for inode->i_lock */
1435 struct nfs_mds_commit_info *mds; 1435 struct nfs_mds_commit_info *mds;
1436 struct pnfs_ds_commit_info *ds; 1436 struct pnfs_ds_commit_info *ds;
1437 struct nfs_direct_req *dreq; /* O_DIRECT request */ 1437 struct nfs_direct_req *dreq; /* O_DIRECT request */