Skip to content

Commit

Permalink
nfsd: eliminate __nfs4_get_fd
Browse files Browse the repository at this point in the history
This is wrapper is pointless, and just obscures what's going on.

Signed-off-by: Jeff Layton <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
  • Loading branch information
jtlayton authored and chucklever committed Feb 20, 2023
1 parent ee97e73 commit edd2f55
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,22 +599,16 @@ put_nfs4_file(struct nfs4_file *fi)
}
}

static struct nfsd_file *
__nfs4_get_fd(struct nfs4_file *f, int oflag)
{
return nfsd_file_get(f->fi_fds[oflag]);
}

static struct nfsd_file *
find_writeable_file_locked(struct nfs4_file *f)
{
struct nfsd_file *ret;

lockdep_assert_held(&f->fi_lock);

ret = __nfs4_get_fd(f, O_WRONLY);
ret = nfsd_file_get(f->fi_fds[O_WRONLY]);
if (!ret)
ret = __nfs4_get_fd(f, O_RDWR);
ret = nfsd_file_get(f->fi_fds[O_RDWR]);
return ret;
}

Expand All @@ -637,9 +631,9 @@ find_readable_file_locked(struct nfs4_file *f)

lockdep_assert_held(&f->fi_lock);

ret = __nfs4_get_fd(f, O_RDONLY);
ret = nfsd_file_get(f->fi_fds[O_RDONLY]);
if (!ret)
ret = __nfs4_get_fd(f, O_RDWR);
ret = nfsd_file_get(f->fi_fds[O_RDWR]);
return ret;
}

Expand All @@ -663,11 +657,11 @@ find_any_file(struct nfs4_file *f)
if (!f)
return NULL;
spin_lock(&f->fi_lock);
ret = __nfs4_get_fd(f, O_RDWR);
ret = nfsd_file_get(f->fi_fds[O_RDWR]);
if (!ret) {
ret = __nfs4_get_fd(f, O_WRONLY);
ret = nfsd_file_get(f->fi_fds[O_WRONLY]);
if (!ret)
ret = __nfs4_get_fd(f, O_RDONLY);
ret = nfsd_file_get(f->fi_fds[O_RDONLY]);
}
spin_unlock(&f->fi_lock);
return ret;
Expand Down

0 comments on commit edd2f55

Please sign in to comment.