Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a942b57b authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* git://git.linux-nfs.org/pub/linux/nfs-2.6:
  NLM,NFSv4: Wait on local locks before we put RPC calls on the wire
  VFS: Add support for the FL_ACCESS flag to flock_lock_file()
  NFSv4: Ensure nfs4_lock_expired() caches delegated locks
  NLM,NFSv4: Don't put UNLOCK requests on the wire unless we hold a lock
  VFS: Allow caller to determine if BSD or posix locks were actually freed
  NFS: Optimise away an excessive GETATTR call when a file is symlinked
  This fixes a panic doing the first READDIR or READDIRPLUS call when:
  NFS: Fix NFS page_state usage
  Revert "Merge branch 'odirect'"
parents 887e5d5f 72dbac37
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -454,7 +454,7 @@ static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *ho
	fl->fl_ops = &nlmclnt_lock_ops;
}

static void do_vfs_lock(struct file_lock *fl)
static int do_vfs_lock(struct file_lock *fl)
{
	int res = 0;
	switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) {
@@ -467,9 +467,7 @@ static void do_vfs_lock(struct file_lock *fl)
		default:
			BUG();
	}
	if (res < 0)
		printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n",
				__FUNCTION__);
	return res;
}

/*
@@ -498,6 +496,7 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
	struct nlm_host	*host = req->a_host;
	struct nlm_res	*resp = &req->a_res;
	struct nlm_wait *block = NULL;
	unsigned char fl_flags = fl->fl_flags;
	int status = -ENOLCK;

	if (!host->h_monitored && nsm_monitor(host) < 0) {
@@ -505,6 +504,10 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
					host->h_name);
		goto out;
	}
	fl->fl_flags |= FL_ACCESS;
	status = do_vfs_lock(fl);
	if (status < 0)
		goto out;

	block = nlmclnt_prepare_block(host, fl);
again:
@@ -539,9 +542,10 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
			up_read(&host->h_rwsem);
			goto again;
		}
		fl->fl_flags |= FL_SLEEP;
		/* Ensure the resulting lock will get added to granted list */
		do_vfs_lock(fl);
		fl->fl_flags = fl_flags | FL_SLEEP;
		if (do_vfs_lock(fl) < 0)
			printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __FUNCTION__);
		up_read(&host->h_rwsem);
	}
	status = nlm_stat_to_errno(resp->status);
@@ -552,6 +556,7 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
		nlmclnt_cancel(host, req->a_args.block, fl);
out:
	nlm_release_call(req);
	fl->fl_flags = fl_flags;
	return status;
}

@@ -606,15 +611,19 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl)
{
	struct nlm_host	*host = req->a_host;
	struct nlm_res	*resp = &req->a_res;
	int		status;
	int status = 0;

	/*
	 * Note: the server is supposed to either grant us the unlock
	 * request, or to deny it with NLM_LCK_DENIED_GRACE_PERIOD. In either
	 * case, we want to unlock.
	 */
	fl->fl_flags |= FL_EXISTS;
	down_read(&host->h_rwsem);
	do_vfs_lock(fl);
	if (do_vfs_lock(fl) == -ENOENT) {
		up_read(&host->h_rwsem);
		goto out;
	}
	up_read(&host->h_rwsem);

	if (req->a_flags & RPC_TASK_ASYNC)
@@ -624,7 +633,6 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl)
	if (status < 0)
		goto out;

	status = 0;
	if (resp->status == NLM_LCK_GRANTED)
		goto out;

+21 −2
Original line number Diff line number Diff line
@@ -725,6 +725,10 @@ static int posix_locks_deadlock(struct file_lock *caller_fl,
/* Try to create a FLOCK lock on filp. We always insert new FLOCK locks
 * at the head of the list, but that's secret knowledge known only to
 * flock_lock_file and posix_lock_file.
 *
 * Note that if called with an FL_EXISTS argument, the caller may determine
 * whether or not a lock was successfully freed by testing the return
 * value for -ENOENT.
 */
static int flock_lock_file(struct file *filp, struct file_lock *request)
{
@@ -735,6 +739,8 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
	int found = 0;

	lock_kernel();
	if (request->fl_flags & FL_ACCESS)
		goto find_conflict;
	for_each_lock(inode, before) {
		struct file_lock *fl = *before;
		if (IS_POSIX(fl))
@@ -750,8 +756,11 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
		break;
	}

	if (request->fl_type == F_UNLCK)
	if (request->fl_type == F_UNLCK) {
		if ((request->fl_flags & FL_EXISTS) && !found)
			error = -ENOENT;
		goto out;
	}

	error = -ENOMEM;
	new_fl = locks_alloc_lock();
@@ -764,6 +773,7 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
	if (found)
		cond_resched();

find_conflict:
	for_each_lock(inode, before) {
		struct file_lock *fl = *before;
		if (IS_POSIX(fl))
@@ -777,6 +787,8 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
			locks_insert_block(fl, request);
		goto out;
	}
	if (request->fl_flags & FL_ACCESS)
		goto out;
	locks_copy_lock(new_fl, request);
	locks_insert_lock(&inode->i_flock, new_fl);
	new_fl = NULL;
@@ -948,8 +960,11 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request

	error = 0;
	if (!added) {
		if (request->fl_type == F_UNLCK)
		if (request->fl_type == F_UNLCK) {
			if (request->fl_flags & FL_EXISTS)
				error = -ENOENT;
			goto out;
		}

		if (!new_fl) {
			error = -ENOLCK;
@@ -996,6 +1011,10 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request
 * Add a POSIX style lock to a file.
 * We merge adjacent & overlapping locks whenever possible.
 * POSIX locks are sorted by owner task, then by starting address
 *
 * Note that if called with an FL_EXISTS argument, the caller may determine
 * whether or not a lock was successfully freed by testing the return
 * value for -ENOENT.
 */
int posix_lock_file(struct file *filp, struct file_lock *fl)
{
+3 −1
Original line number Diff line number Diff line
@@ -690,7 +690,9 @@ int nfs_lookup_verify_inode(struct inode *inode, struct nameidata *nd)
			goto out_force;
		/* This is an open(2) */
		if (nfs_lookup_check_intent(nd, LOOKUP_OPEN) != 0 &&
				!(server->flags & NFS_MOUNT_NOCTO))
				!(server->flags & NFS_MOUNT_NOCTO) &&
				(S_ISREG(inode->i_mode) ||
				 S_ISDIR(inode->i_mode)))
			goto out_force;
	}
	return nfs_revalidate_inode(server, inode);
+201 −234

File changed.

Preview size limit exceeded, changes collapsed.

+41 −33

File changed.

Preview size limit exceeded, changes collapsed.

Loading