aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/pnfs.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-09-26 11:21:40 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-09-28 16:03:08 -0400
commitf86bbcf85db32596a0484477d1b8042005709049 (patch)
tree38c8e879c737cc4a333fc44ca37430e07706b941 /fs/nfs/pnfs.c
parent78e4e05c643768af170e5a4b21712d9a7a26cce5 (diff)
NFSv4.1: Replace dprintk() in pnfs_update_layout with something less buggy
Dereferencing nfsi->layout in order to read plh_flags without holding a spin lock is bug prone. Furthermore, the dprintk() tells you nothing about whether or not the call succeeded. Replace it with something that tells you about whether or not a valid layout segment was returned for the inode in question. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/pnfs.c')
-rw-r--r--fs/nfs/pnfs.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 498af8779959..df45acaf91f7 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1027,17 +1027,15 @@ pnfs_update_layout(struct inode *ino,
1027 bool first = false; 1027 bool first = false;
1028 1028
1029 if (!pnfs_enabled_sb(NFS_SERVER(ino))) 1029 if (!pnfs_enabled_sb(NFS_SERVER(ino)))
1030 return NULL; 1030 goto out;
1031 1031
1032 if (pnfs_within_mdsthreshold(ctx, ino, iomode)) 1032 if (pnfs_within_mdsthreshold(ctx, ino, iomode))
1033 return NULL; 1033 goto out;
1034 1034
1035 spin_lock(&ino->i_lock); 1035 spin_lock(&ino->i_lock);
1036 lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags); 1036 lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags);
1037 if (lo == NULL) { 1037 if (lo == NULL)
1038 dprintk("%s ERROR: can't get pnfs_layout_hdr\n", __func__);
1039 goto out_unlock; 1038 goto out_unlock;
1040 }
1041 1039
1042 /* Do we even need to bother with this? */ 1040 /* Do we even need to bother with this? */
1043 if (test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) { 1041 if (test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) {
@@ -1093,8 +1091,14 @@ pnfs_update_layout(struct inode *ino,
1093 atomic_dec(&lo->plh_outstanding); 1091 atomic_dec(&lo->plh_outstanding);
1094 pnfs_put_layout_hdr(lo); 1092 pnfs_put_layout_hdr(lo);
1095out: 1093out:
1096 dprintk("%s end, state 0x%lx lseg %p\n", __func__, 1094 dprintk("%s: inode %s/%llu pNFS layout segment %s for "
1097 nfsi->layout ? nfsi->layout->plh_flags : -1, lseg); 1095 "(%s, offset: %llu, length: %llu)\n",
1096 __func__, ino->i_sb->s_id,
1097 (unsigned long long)NFS_FILEID(ino),
1098 lseg == NULL ? "not found" : "found",
1099 iomode==IOMODE_RW ? "read/write" : "read-only",
1100 (unsigned long long)pos,
1101 (unsigned long long)count);
1098 return lseg; 1102 return lseg;
1099out_unlock: 1103out_unlock:
1100 spin_unlock(&ino->i_lock); 1104 spin_unlock(&ino->i_lock);