Skip to content

Commit d564d2c

Browse files
ChenXiaoSongTrond Myklebust
authored andcommitted
NFSv4: check FMODE_EXEC from open context mode in nfs4_opendata_access()
After converting file f_flags to open context mode by flags_to_mode(), open context mode will have FMODE_EXEC when file open for exec, so we check FMODE_EXEC from open context mode. No functional change, just simplify the code. Signed-off-by: ChenXiaoSong <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 6f1c1d9 commit d564d2c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

fs/nfs/nfs4proc.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,8 +2630,7 @@ static int _nfs4_recover_proc_open(struct nfs4_opendata *data)
26302630
*/
26312631
static int nfs4_opendata_access(const struct cred *cred,
26322632
struct nfs4_opendata *opendata,
2633-
struct nfs4_state *state, fmode_t fmode,
2634-
int openflags)
2633+
struct nfs4_state *state, fmode_t fmode)
26352634
{
26362635
struct nfs_access_entry cache;
26372636
u32 mask, flags;
@@ -2642,11 +2641,7 @@ static int nfs4_opendata_access(const struct cred *cred,
26422641
return 0;
26432642

26442643
mask = 0;
2645-
/*
2646-
* Use openflags to check for exec, because fmode won't
2647-
* always have FMODE_EXEC set when file open for exec.
2648-
*/
2649-
if (openflags & __FMODE_EXEC) {
2644+
if (fmode & FMODE_EXEC) {
26502645
/* ONLY check for exec rights */
26512646
if (S_ISDIR(state->inode->i_mode))
26522647
mask = NFS4_ACCESS_LOOKUP;
@@ -3034,7 +3029,7 @@ static unsigned nfs4_exclusive_attrset(struct nfs4_opendata *opendata,
30343029
}
30353030

30363031
static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
3037-
int flags, struct nfs_open_context *ctx)
3032+
struct nfs_open_context *ctx)
30383033
{
30393034
struct nfs4_state_owner *sp = opendata->owner;
30403035
struct nfs_server *server = sp->so_server;
@@ -3095,8 +3090,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
30953090
/* Parse layoutget results before we check for access */
30963091
pnfs_parse_lgopen(state->inode, opendata->lgp, ctx);
30973092

3098-
ret = nfs4_opendata_access(sp->so_cred, opendata, state,
3099-
acc_mode, flags);
3093+
ret = nfs4_opendata_access(sp->so_cred, opendata, state, acc_mode);
31003094
if (ret != 0)
31013095
goto out;
31023096

@@ -3170,7 +3164,7 @@ static int _nfs4_do_open(struct inode *dir,
31703164
if (d_really_is_positive(dentry))
31713165
opendata->state = nfs4_get_open_state(d_inode(dentry), sp);
31723166

3173-
status = _nfs4_open_and_get_state(opendata, flags, ctx);
3167+
status = _nfs4_open_and_get_state(opendata, ctx);
31743168
if (status != 0)
31753169
goto err_opendata_put;
31763170
state = ctx->state;

0 commit comments

Comments
 (0)