From: Pavel Shilovsky <piastry@etersoft.ru>
To: linux-kernel@vger.kernel.org
Cc: linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-nfs@vger.kernel.org, wine-devel@winehq.org
Subject: [PATCH v5 5/7] NFSv4: Add O_DENY* open flags support
Date: Tue, 9 Apr 2013 16:40:25 +0400 [thread overview]
Message-ID: <1365511227-17626-6-git-send-email-piastry@etersoft.ru> (raw)
In-Reply-To: <1365511227-17626-1-git-send-email-piastry@etersoft.ru>
by passing these flags to NFSv4 open request. Also make it return
-EBUSY on share conflicts with other opens.
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
---
fs/nfs/internal.h | 3 ++-
fs/nfs/nfs4proc.c | 4 +++-
fs/nfs/nfs4super.c | 9 ++++++---
fs/nfs/nfs4xdr.c | 21 +++++++++++++++++----
fs/nfs/super.c | 7 +++++--
5 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index f0e6c7d..c770830 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -6,7 +6,8 @@
#include <linux/mount.h>
#include <linux/security.h>
-#define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS)
+#define NFS_MS_MASK (MS_RDONLY | MS_NOSUID | MS_NODEV | MS_NOEXEC | \
+ MS_SYNCHRONOUS | MS_SHARELOCK)
struct nfs_string;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 3cb5e77..5d44763 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -100,7 +100,7 @@ static int nfs4_map_errors(int err)
case -NFS4ERR_BADNAME:
return -EINVAL;
case -NFS4ERR_SHARE_DENIED:
- return -EACCES;
+ return -EBUSY;
case -NFS4ERR_MINOR_VERS_MISMATCH:
return -EPROTONOSUPPORT;
case -NFS4ERR_ACCESS:
@@ -793,6 +793,8 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
atomic_inc(&sp->so_count);
p->o_arg.fh = NFS_FH(dir);
p->o_arg.open_flags = flags;
+ if (!IS_SHARELOCK(dir))
+ p->o_arg.open_flags &= ~(O_DENYREAD | O_DENYWRITE);
p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);
/* don't put an ACCESS op in OPEN compound if O_EXCL, because ACCESS
* will return permission denied for all bits until close */
diff --git a/fs/nfs/nfs4super.c b/fs/nfs/nfs4super.c
index 84d2e9e..ca791cd 100644
--- a/fs/nfs/nfs4super.c
+++ b/fs/nfs/nfs4super.c
@@ -28,7 +28,8 @@ static struct file_system_type nfs4_remote_fs_type = {
.name = "nfs4",
.mount = nfs4_remote_mount,
.kill_sb = nfs_kill_super,
- .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
+ .fs_flags = FS_RENAME_DOES_D_MOVE | FS_REVAL_DOT |
+ FS_BINARY_MOUNTDATA | FS_DOES_SHARELOCK,
};
static struct file_system_type nfs4_remote_referral_fs_type = {
@@ -36,7 +37,8 @@ static struct file_system_type nfs4_remote_referral_fs_type = {
.name = "nfs4",
.mount = nfs4_remote_referral_mount,
.kill_sb = nfs_kill_super,
- .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
+ .fs_flags = FS_RENAME_DOES_D_MOVE | FS_REVAL_DOT |
+ FS_BINARY_MOUNTDATA | FS_DOES_SHARELOCK,
};
struct file_system_type nfs4_referral_fs_type = {
@@ -44,7 +46,8 @@ struct file_system_type nfs4_referral_fs_type = {
.name = "nfs4",
.mount = nfs4_referral_mount,
.kill_sb = nfs_kill_super,
- .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
+ .fs_flags = FS_RENAME_DOES_D_MOVE | FS_REVAL_DOT |
+ FS_BINARY_MOUNTDATA | FS_DOES_SHARELOCK,
};
static const struct super_operations nfs4_sops = {
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 26b1439..8fe0221 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1325,7 +1325,8 @@ static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struc
encode_string(xdr, name->len, name->name);
}
-static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode)
+static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode,
+ int open_flags)
{
__be32 *p;
@@ -1343,7 +1344,19 @@ static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode)
default:
*p++ = cpu_to_be32(0);
}
- *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */
+ switch (open_flags & (O_DENYREAD|O_DENYWRITE)) {
+ case O_DENYREAD:
+ *p = cpu_to_be32(NFS4_SHARE_DENY_READ);
+ break;
+ case O_DENYWRITE:
+ *p = cpu_to_be32(NFS4_SHARE_DENY_WRITE);
+ break;
+ case O_DENYREAD|O_DENYWRITE:
+ *p = cpu_to_be32(NFS4_SHARE_DENY_BOTH);
+ break;
+ default:
+ *p = cpu_to_be32(0);
+ }
}
static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg)
@@ -1354,7 +1367,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
* owner 4 = 32
*/
encode_nfs4_seqid(xdr, arg->seqid);
- encode_share_access(xdr, arg->fmode);
+ encode_share_access(xdr, arg->fmode, arg->open_flags);
p = reserve_space(xdr, 36);
p = xdr_encode_hyper(p, arg->clientid);
*p++ = cpu_to_be32(24);
@@ -1491,7 +1504,7 @@ static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_close
encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr);
encode_nfs4_stateid(xdr, arg->stateid);
encode_nfs4_seqid(xdr, arg->seqid);
- encode_share_access(xdr, arg->fmode);
+ encode_share_access(xdr, arg->fmode, 0);
}
static void
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index b056b16..cf9db61 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -331,7 +331,8 @@ struct file_system_type nfs4_fs_type = {
.name = "nfs4",
.mount = nfs_fs_mount,
.kill_sb = nfs_kill_super,
- .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
+ .fs_flags = FS_RENAME_DOES_D_MOVE | FS_REVAL_DOT |
+ FS_BINARY_MOUNTDATA | FS_DOES_SHARELOCK,
};
EXPORT_SYMBOL_GPL(nfs4_fs_type);
@@ -2589,6 +2590,8 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags,
struct nfs_server *server;
struct dentry *mntroot = ERR_PTR(-ENOMEM);
struct nfs_subversion *nfs_mod = NFS_SB(data->sb)->nfs_client->cl_nfs_mod;
+ /* save sharelock option */
+ int sharelock = data->sb->s_flags & MS_SHARELOCK;
dprintk("--> nfs_xdev_mount()\n");
@@ -2600,7 +2603,7 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags,
if (IS_ERR(server))
mntroot = ERR_CAST(server);
else
- mntroot = nfs_fs_mount_common(server, flags,
+ mntroot = nfs_fs_mount_common(server, flags | sharelock,
dev_name, &mount_info, nfs_mod);
dprintk("<-- nfs_xdev_mount() = %ld\n",
--
1.8.1.5
next prev parent reply other threads:[~2013-04-09 12:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-09 12:40 [PATCH v5 0/7] Add O_DENY* support for VFS and CIFS/NFS Pavel Shilovsky
2013-04-09 12:40 ` [PATCH v5 1/7] fcntl: Introduce new O_DENY* open flags Pavel Shilovsky
[not found] ` <1365511227-17626-2-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2013-04-10 11:18 ` Jeff Layton
[not found] ` <20130410071824.5a37cbaf-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2013-04-10 13:24 ` Pavel Shilovsky
2013-04-10 16:27 ` Frank Filz
2013-04-09 12:40 ` [PATCH v5 2/7] CIFS: Add share_access parm to open request Pavel Shilovsky
2013-04-09 12:40 ` [PATCH v5 3/7] CIFS: Add O_DENY* open flags support Pavel Shilovsky
2013-04-09 12:40 ` [PATCH v5 4/7] CIFS: Use NT_CREATE_ANDX command for forcemand mounts Pavel Shilovsky
[not found] ` <1365511227-17626-5-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2013-04-10 11:11 ` Jeff Layton
[not found] ` <20130410071144.08ef2983-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2013-04-10 11:45 ` Pavel Shilovsky
2013-04-10 12:12 ` Jeff Layton
2013-04-10 13:59 ` Pavel Shilovsky
2013-04-09 12:40 ` Pavel Shilovsky [this message]
2013-04-09 12:40 ` [PATCH v5 6/7] NFSD: Pass share reservations flags to VFS Pavel Shilovsky
[not found] ` <1365511227-17626-1-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2013-04-09 12:40 ` [PATCH v5 7/7] locks: Disable LOCK_MAND support for MS_SHARELOCK mounts Pavel Shilovsky
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=1365511227-17626-6-git-send-email-piastry@etersoft.ru \
--to=piastry@etersoft.ru \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=wine-devel@winehq.org \
/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;
as well as URLs for NNTP newsgroup(s).