Commit f86bbcf8 authored by Trond Myklebust's avatar Trond Myklebust

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: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 78e4e05c
...@@ -1027,17 +1027,15 @@ pnfs_update_layout(struct inode *ino, ...@@ -1027,17 +1027,15 @@ pnfs_update_layout(struct inode *ino,
bool first = false; bool first = false;
if (!pnfs_enabled_sb(NFS_SERVER(ino))) if (!pnfs_enabled_sb(NFS_SERVER(ino)))
return NULL; goto out;
if (pnfs_within_mdsthreshold(ctx, ino, iomode)) if (pnfs_within_mdsthreshold(ctx, ino, iomode))
return NULL; goto out;
spin_lock(&ino->i_lock); spin_lock(&ino->i_lock);
lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags); lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags);
if (lo == NULL) { if (lo == NULL)
dprintk("%s ERROR: can't get pnfs_layout_hdr\n", __func__);
goto out_unlock; goto out_unlock;
}
/* Do we even need to bother with this? */ /* Do we even need to bother with this? */
if (test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) { if (test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) {
...@@ -1093,8 +1091,14 @@ pnfs_update_layout(struct inode *ino, ...@@ -1093,8 +1091,14 @@ pnfs_update_layout(struct inode *ino,
atomic_dec(&lo->plh_outstanding); atomic_dec(&lo->plh_outstanding);
pnfs_put_layout_hdr(lo); pnfs_put_layout_hdr(lo);
out: out:
dprintk("%s end, state 0x%lx lseg %p\n", __func__, dprintk("%s: inode %s/%llu pNFS layout segment %s for "
nfsi->layout ? nfsi->layout->plh_flags : -1, lseg); "(%s, offset: %llu, length: %llu)\n",
__func__, ino->i_sb->s_id,
(unsigned long long)NFS_FILEID(ino),
lseg == NULL ? "not found" : "found",
iomode==IOMODE_RW ? "read/write" : "read-only",
(unsigned long long)pos,
(unsigned long long)count);
return lseg; return lseg;
out_unlock: out_unlock:
spin_unlock(&ino->i_lock); spin_unlock(&ino->i_lock);
......
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