mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: akpm@linux-foundation.org
Cc: hch@infradead.org, bfields@fieldses.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Trond Myklebust <trond.myklebust@fys.uio.no>
Subject: [patch 1/9] lockd: dont return EAGAIN for a permanent error
Date: Thu, 15 May 2008 21:50:20 +0200	[thread overview]
Message-ID: <20080515195103.521911468@szeredi.hu> (raw)
In-Reply-To: <20080515195019.754545421@szeredi.hu>

[-- Attachment #1: lockd_fix.patch --]
[-- Type: text/plain, Size: 2238 bytes --]

From: Miklos Szeredi <mszeredi@suse.cz>

Fix nlm_fopen() to return NLM_FAILED (or NLM_LCK_DENIED_NOLOCKS)
instead of NLM_LCK_DENIED.  The latter means the lock request failed
because of a conflicting lock (i.e. a temporary error), which is wrong
in this case.

Also fix the client to return ENOLCK instead of EAGAIN if a blocking
lock request returns with NLM_LOCK_DENIED.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
CC: Trond Myklebust <trond.myklebust@fys.uio.no>
CC: "J. Bruce Fields" <bfields@fieldses.org>
---
 fs/lockd/clntproc.c |   10 +++++++++-
 fs/nfsd/lockd.c     |   13 +++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)

Index: linux-2.6/fs/lockd/clntproc.c
===================================================================
--- linux-2.6.orig/fs/lockd/clntproc.c	2008-05-15 17:54:30.000000000 +0200
+++ linux-2.6/fs/lockd/clntproc.c	2008-05-15 17:59:41.000000000 +0200
@@ -580,7 +580,15 @@ again:
 	}
 	if (status < 0)
 		goto out_unlock;
-	status = nlm_stat_to_errno(resp->status);
+	/*
+	 * EAGAIN doesn't make sense for sleeping locks, and in some
+	 * cases NLM_LCK_DENIED is returned for a permanent error.  So
+	 * turn it into an ENOLCK.
+	 */
+	if (resp->status == nlm_lck_denied && (fl_flags & FL_SLEEP))
+		status = -ENOLCK;
+	else
+		status = nlm_stat_to_errno(resp->status);
 out_unblock:
 	nlmclnt_finish_block(block);
 out:
Index: linux-2.6/fs/nfsd/lockd.c
===================================================================
--- linux-2.6.orig/fs/nfsd/lockd.c	2008-05-15 17:54:30.000000000 +0200
+++ linux-2.6/fs/nfsd/lockd.c	2008-05-15 17:57:45.000000000 +0200
@@ -19,6 +19,13 @@
 
 #define NFSDDBG_FACILITY		NFSDDBG_LOCKD
 
+#ifdef CONFIG_LOCKD_V4
+#define nlm_stale_fh	nlm4_stale_fh
+#define nlm_failed	nlm4_failed
+#else
+#define nlm_stale_fh	nlm_lck_denied_nolocks
+#define nlm_failed	nlm_lck_denied_nolocks
+#endif
 /*
  * Note: we hold the dentry use count while the file is open.
  */
@@ -47,12 +54,10 @@ nlm_fopen(struct svc_rqst *rqstp, struct
 		return 0;
 	case nfserr_dropit:
 		return nlm_drop_reply;
-#ifdef CONFIG_LOCKD_V4
 	case nfserr_stale:
-		return nlm4_stale_fh;
-#endif
+		return nlm_stale_fh;
 	default:
-		return nlm_lck_denied;
+		return nlm_failed;
 	}
 }
 

--

  reply	other threads:[~2008-05-15 19:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 19:50 [patch 0/9] file locking fixes + fuse nfs export support (v2) Miklos Szeredi
2008-05-15 19:50 ` Miklos Szeredi [this message]
2008-05-20 18:47   ` [patch 1/9] lockd: dont return EAGAIN for a permanent error J. Bruce Fields
2008-05-15 19:50 ` [patch 2/9] locks: add special return value for asynchronous locks Miklos Szeredi
2008-05-15 19:50 ` [patch 3/9] locks: cleanup code duplication Miklos Szeredi
2008-05-15 19:50 ` [patch 4/9] locks: allow ->lock() to return FILE_LOCK_DEFERRED Miklos Szeredi
2008-05-15 19:50 ` [patch 5/9] fuse: prepare lookup for nfs export Miklos Szeredi
2008-05-15 19:50 ` [patch 6/9] fuse: add export operations Miklos Szeredi
2008-05-15 19:50 ` [patch 7/9] fuse: add fuse_lookup_name() helper Miklos Szeredi
2008-05-15 19:50 ` [patch 8/9] fuse: nfs export special lookups Miklos Szeredi
2008-05-15 19:50 ` [patch 9/9] fuse: lockd support Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080515195103.521911468@szeredi.hu \
    --to=miklos@szeredi.hu \
    --cc=akpm@linux-foundation.org \
    --cc=bfields@fieldses.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trond.myklebust@fys.uio.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®