Skip to content

Commit 286ba84

Browse files
committed
Merge tag 'nfs-for-4.13-3' of git://git.linux-nfs.org/projects/anna/linux-nfs
Pull NFS client fixes from Anna Schumaker: "More NFS client bugfixes for 4.13. Most of these fix locking bugs that Ben and Neil noticed, but I also have a patch to fix one more access bug that was reported after last week. Stable fixes: - Fix a race where CB_NOTIFY_LOCK fails to wake a waiter - Invalidate file size when taking a lock to prevent corruption Other fixes: - Don't excessively generate tiny writes with fallocate - Use the raw NFS access mask in nfs4_opendata_access()" * tag 'nfs-for-4.13-3' of git://git.linux-nfs.org/projects/anna/linux-nfs: NFSv4.1: Fix a race where CB_NOTIFY_LOCK fails to wake a waiter NFS: Optimize fallocate by refreshing mapping when needed. NFS: invalidate file size when taking a lock. NFS: Use raw NFS access mask in nfs4_opendata_access()
2 parents 19993e7 + b7dbcc0 commit 286ba84

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

fs/nfs/file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,8 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
617617
if (result)
618618
goto out;
619619
}
620+
if (iocb->ki_pos > i_size_read(inode))
621+
nfs_revalidate_mapping(inode, file->f_mapping);
620622

621623
nfs_start_io_write(inode);
622624
result = generic_write_checks(iocb, from);
@@ -750,7 +752,7 @@ do_setlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
750752
*/
751753
nfs_sync_mapping(filp->f_mapping);
752754
if (!NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
753-
nfs_zap_mapping(inode, filp->f_mapping);
755+
nfs_zap_caches(inode);
754756
out:
755757
return status;
756758
}

fs/nfs/nfs4proc.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,7 +2236,7 @@ static int nfs4_opendata_access(struct rpc_cred *cred,
22362236
int openflags)
22372237
{
22382238
struct nfs_access_entry cache;
2239-
u32 mask;
2239+
u32 mask, flags;
22402240

22412241
/* access call failed or for some reason the server doesn't
22422242
* support any access modes -- defer access call until later */
@@ -2250,16 +2250,20 @@ static int nfs4_opendata_access(struct rpc_cred *cred,
22502250
*/
22512251
if (openflags & __FMODE_EXEC) {
22522252
/* ONLY check for exec rights */
2253-
mask = MAY_EXEC;
2253+
if (S_ISDIR(state->inode->i_mode))
2254+
mask = NFS4_ACCESS_LOOKUP;
2255+
else
2256+
mask = NFS4_ACCESS_EXECUTE;
22542257
} else if ((fmode & FMODE_READ) && !opendata->file_created)
2255-
mask = MAY_READ;
2258+
mask = NFS4_ACCESS_READ;
22562259

22572260
cache.cred = cred;
22582261
cache.jiffies = jiffies;
22592262
nfs_access_set_mask(&cache, opendata->o_res.access_result);
22602263
nfs_access_add_cache(state->inode, &cache);
22612264

2262-
if ((mask & ~cache.mask & (MAY_READ | MAY_EXEC)) == 0)
2265+
flags = NFS4_ACCESS_READ | NFS4_ACCESS_EXECUTE | NFS4_ACCESS_LOOKUP;
2266+
if ((mask & ~cache.mask & flags) == 0)
22632267
return 0;
22642268

22652269
return -EACCES;
@@ -6492,7 +6496,7 @@ nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
64926496
set_current_state(TASK_INTERRUPTIBLE);
64936497
spin_unlock_irqrestore(&q->lock, flags);
64946498

6495-
freezable_schedule_timeout_interruptible(NFS4_LOCK_MAXTIMEOUT);
6499+
freezable_schedule_timeout(NFS4_LOCK_MAXTIMEOUT);
64966500
}
64976501

64986502
finish_wait(q, &wait);

0 commit comments

Comments
 (0)