Re: [PATCH v6 2/7] VFS: Add O_DENYDELETE support for VFS

2013-06-11 Thread Jeff Layton
; *filp) > return 0; > } > > +static inline int sharelock_may_delete(struct dentry *dentry) > +{ > + return 0; > +} > + > static inline void lock_flocks(void) > { > } > diff --git a/include/uapi/asm-generic/fcntl.h > b/include/uapi/asm-generic/fcntl.h > index 5ac0d49..a3e6349 100644 > --- a/include/uapi/asm-generic/fcntl.h > +++ b/include/uapi/asm-generic/fcntl.h > @@ -167,6 +167,7 @@ struct f_owner_ex { > blocking */ > #define LOCK_UN 8 /* remove lock */ > > +#define LOCK_DELETE 16 /* which allows to delete a file */ > #define LOCK_MAND32 /* This is a mandatory flock ... */ > #define LOCK_READ64 /* which allows concurrent read operations */ > #define LOCK_WRITE 128 /* which allows concurrent write operations */ -- Jeff Layton

Re: [PATCH v6 1/7] VFS: Introduce new O_DENY* open flags

2013-06-11 Thread Jeff Layton
4 /* File is locked with a sharelock */ > + ^ I think you're missing some definitions of this on more exotic arches such as SPARC, PARISC, etc. This should probably also be done in a separate patch instead of slipping it in here. > #endif > diff --git a/include/uapi/asm-generic/fcntl.h > b/include/uapi/asm-generic/fcntl.h > index a48937d..5ac0d49 100644 > --- a/include/uapi/asm-generic/fcntl.h > +++ b/include/uapi/asm-generic/fcntl.h > @@ -84,6 +84,17 @@ > #define O_PATH 01000 > #endif > > +#ifndef O_DENYREAD > +#define O_DENYREAD 02000 /* Do not permit read access */ > +#endif > +#ifndef O_DENYWRITE > +#define O_DENYWRITE 04000 /* Do not permit write access */ > +#endif > +/* FMODE_NONOTIFY01 */ > +#ifndef O_DENYDELETE > +#define O_DENYDELETE 02 /* Do not permit delete or rename */ > +#endif > + > #ifndef O_NDELAY > #define O_NDELAY O_NONBLOCK > #endif > diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h > index c7fc1e6..2af7269 100644 > --- a/include/uapi/linux/fs.h > +++ b/include/uapi/linux/fs.h > @@ -86,6 +86,7 @@ struct inodes_stat_t { > #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */ > #define MS_I_VERSION (1<<23) /* Update inode I_version field */ > #define MS_STRICTATIME (1<<24) /* Always perform atime updates */ > +#define MS_SHARELOCK (1<<25) /* Allow share locks on an FS */ > > /* These sb flags are internal to the kernel */ > #define MS_SNAP_STABLE (1<<27) /* Snapshot pages during writeback, if > needed */ -- Jeff Layton

Re: [PATCH v6 2/7] VFS: Add O_DENYDELETE support for VFS

2013-05-13 Thread Jeff Layton
On Mon, 13 May 2013 21:50:23 +0400 Pavel Shilovsky wrote: > 2013/5/10 Jeff Layton : > > On Fri, 26 Apr 2013 16:04:16 +0400 > > Pavel Shilovsky wrote: > > > >> Introduce new LOCK_DELETE flock flag that is suggested to be used > >> intern

Re: [PATCH v6 2/7] VFS: Add O_DENYDELETE support for VFS

2013-05-11 Thread Jeff Layton
> extern void unlock_flocks(void); > #else /* !CONFIG_FILE_LOCKING */ > @@ -1159,6 +1160,11 @@ static inline int sharelock_lock_file(struct file > *filp) > return 0; > } > > +static inline int sharelock_may_delete(struct dentry *dentry) > +{ > + return 0; > +} > + > static inline void lock_flocks(void) > { > } > diff --git a/include/uapi/asm-generic/fcntl.h > b/include/uapi/asm-generic/fcntl.h > index 5ac0d49..a3e6349 100644 > --- a/include/uapi/asm-generic/fcntl.h > +++ b/include/uapi/asm-generic/fcntl.h > @@ -167,6 +167,7 @@ struct f_owner_ex { > blocking */ > #define LOCK_UN 8 /* remove lock */ > > +#define LOCK_DELETE 16 /* which allows to delete a file */ > #define LOCK_MAND32 /* This is a mandatory flock ... */ > #define LOCK_READ64 /* which allows concurrent read operations */ > #define LOCK_WRITE 128 /* which allows concurrent write operations */ -- Jeff Layton

Re: [PATCH v5 4/7] CIFS: Use NT_CREATE_ANDX command for forcemand mounts

2013-04-10 Thread Jeff Layton
On Wed, 10 Apr 2013 15:45:33 +0400 Pavel Shilovsky wrote: > 2013/4/10 Jeff Layton : > > On Tue, 9 Apr 2013 16:40:24 +0400 > > Pavel Shilovsky wrote: > > > >> forcemand mount option now lets us use Windows mandatory style of > >> byte-range locks even if s

Re: [PATCH v5 1/7] fcntl: Introduce new O_DENY* open flags

2013-04-10 Thread Jeff Layton
> /* > diff --git a/include/uapi/asm-generic/fcntl.h > b/include/uapi/asm-generic/fcntl.h > index a48937d..5ac0d49 100644 > --- a/include/uapi/asm-generic/fcntl.h > +++ b/include/uapi/asm-generic/fcntl.h > @@ -84,6 +84,17 @@ > #define O_PATH 01000 > #endif > > +#ifndef O_DENYREAD > +#define O_DENYREAD 02000 /* Do not permit read access */ > +#endif > +#ifndef O_DENYWRITE > +#define O_DENYWRITE 04000 /* Do not permit write access */ > +#endif > +/* FMODE_NONOTIFY01 */ > +#ifndef O_DENYDELETE > +#define O_DENYDELETE 02 /* Do not permit delete or rename */ > +#endif > + You're adding O_DENYDELETE here, but there's no support for it in the patchset aside from the passthrough in the cifs code. Is that intentional? What happens if I specify O_DENYDELETE on a non-cifs fs that was mounted with "sharelock"? I assume it's just ignored? > #ifndef O_NDELAY > #define O_NDELAY O_NONBLOCK > #endif > diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h > index 780d4c6..f1925f7 100644 > --- a/include/uapi/linux/fs.h > +++ b/include/uapi/linux/fs.h > @@ -86,6 +86,7 @@ struct inodes_stat_t { > #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */ > #define MS_I_VERSION (1<<23) /* Update inode I_version field */ > #define MS_STRICTATIME (1<<24) /* Always perform atime updates */ > +#define MS_SHARELOCK (1<<25) /* Allow share locks on an FS */ > #define MS_NOSEC (1<<28) > #define MS_BORN (1<<29) > #define MS_ACTIVE(1<<30) -- Jeff Layton

Re: [PATCH v5 4/7] CIFS: Use NT_CREATE_ANDX command for forcemand mounts

2013-04-10 Thread Jeff Layton
oplock = 0; > > if (tcon->unix_ext && cap_unix(tcon->ses) && > + ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0) && > (CIFS_UNIX_POSIX_PATH_OPS_CAP & > le64_to_cpu(tcon->fsUnixInfo.Capability))) { > /* I'm trying to understand why "forcemand" would matter here. Wouldn't you just want to switch to using NT_CREATE_ANDX if O_DENY* is set instead? What happens if I didn't mount with forcemand and then try to use O_DENY*? -- Jeff Layton

Re: [PATCH v4 3/7] CIFS: Add O_DENY* open flags support

2013-04-08 Thread Jeff Layton
y->d_inode)) > return error; > > + /* > + * Don't set a lock on CIFS file systems because they can process it > + * themselves. > + */ > + if (!strncmp(fsname, "cifs", 4)) > + return error; > + NAK This is really nasty. Instead of doing this, you should instead create a new file_system_type->fs_flags value. Then, set that flag for cifs and nfs4, and test it here. > error = flock_make_lock(filp, &lock, deny_flags_to_cmd(filp->f_flags)); > if (error) > return error; -- Jeff Layton

Re: [PATCH v3 6/7] NFSv4: Add O_DENY* open flags support

2013-04-04 Thread Jeff Layton
On Thu, 4 Apr 2013 14:30:12 +0400 Pavel Shilovsky wrote: > 2013/3/12 Jeff Layton : > > On Mon, 11 Mar 2013 14:54:34 -0400 > > Jeff Layton wrote: > > > >> On Thu, 28 Feb 2013 19:25:32 +0400 > >> Pavel Shilovsky wrote: > >> >

Re: [PATCH v3 6/7] NFSv4: Add O_DENY* open flags support

2013-03-13 Thread Jeff Layton
On Mon, 11 Mar 2013 14:54:34 -0400 Jeff Layton wrote: > On Thu, 28 Feb 2013 19:25:32 +0400 > Pavel Shilovsky wrote: > > > by passing these flags to NFSv4 open request. > > > > Signed-off-by: Pavel Shilovsky > > --- > > fs/nfs/nfs4xdr.c | 24 +

Re: [PATCH v3 7/7] NFSD: Pass share reservations flags to VFS

2013-03-12 Thread Jeff Layton
On Mon, 11 Mar 2013 15:36:38 -0400 "J. Bruce Fields" wrote: > On Mon, Mar 11, 2013 at 03:05:40PM -0400, Jeff Layton wrote: > > knfsd has some code already to handle share reservations internally. > > Nothing outside of knfsd is aware of these reservations, of course so

Re: [PATCH v3 2/7] vfs: Add O_DENYREAD/WRITE flags support for open syscall

2013-03-12 Thread Jeff Layton
On Mon, 11 Mar 2013 22:57:27 +0400 Pavel Shilovsky wrote: > 2013/3/11 Jeff Layton : > > On Thu, 28 Feb 2013 19:25:28 +0400 > > Pavel Shilovsky wrote: > > > >> If O_DENYMAND flag is specified, O_DENYREAD/WRITE/MAND flags are > >> translated to flock'

Re: [PATCH v3 7/7] NFSD: Pass share reservations flags to VFS

2013-03-12 Thread Jeff Layton
sd is aware of these reservations, of course so moving to a vfs-level object for it would be a marked improvement. It doesn't look like this patch removes any of that old code though. I think it probably should, or there ought to be some consideration of how this new stuff will mesh with it. I think you have 2 choices here: 1/ rip out the old share reservation code altogether and require that filesystems mount with -o sharemand or whatever if they want to allow their enforcement 2/ make knfsd fall back to using the internal share reservation code when the mount option isn't enabled Personally, I think #1 would be fine, but Bruce may want to weigh in on what he'd prefer. -- Jeff Layton

Re: [PATCH v3 6/7] NFSv4: Add O_DENY* open flags support

2013-03-12 Thread Jeff Layton
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 Other than that, this seems reasonable. Acked-by: Jeff Layton

Re: [PATCH v3 4/7] CIFS: Use NT_CREATE_ANDX command for forcemand mounts

2013-03-12 Thread Jeff Layton
ock = 0; > > if (tcon->unix_ext && cap_unix(tcon->ses) && > + ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0) && > (CIFS_UNIX_POSIX_PATH_OPS_CAP & > le64_to_cpu(tcon->fsUnixInfo.Capability))) { > /* Sounds reasonable... Acked-by: Jeff Layton

Re: [PATCH v3 3/7] CIFS: Add O_DENY* open flags support

2013-03-12 Thread Jeff Layton
(used in create though) */ > req->FileAttributes = cpu_to_le32(file_attributes); > - req->ShareAccess = FILE_SHARE_ALL_LE; > + req->ShareAccess = cpu_to_le32(share_access); > req->CreateDisposition = cpu_to_le32(create_disposition); > req->CreateOptions = cpu_to_le32(create_options); > uni_path_len = (2 * UniStrnlen((wchar_t *)path, PATH_MAX)) + 2; > diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h > index 2aa3535..edff8f6 100644 > --- a/fs/cifs/smb2proto.h > +++ b/fs/cifs/smb2proto.h > @@ -86,9 +86,10 @@ extern int smb2_create_hardlink(const unsigned int xid, > struct cifs_tcon *tcon, > > extern int smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, > const char *full_path, int disposition, > - int desired_access, int create_options, > - struct cifs_fid *fid, __u32 *oplock, > - FILE_ALL_INFO *buf, struct cifs_sb_info *cifs_sb); > + int desired_access, int share_access, > + int create_options, struct cifs_fid *fid, > + __u32 *oplock, FILE_ALL_INFO *buf, > + struct cifs_sb_info *cifs_sb); > extern void smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 > oplock); > extern int smb2_unlock_range(struct cifsFileInfo *cfile, >struct file_lock *flock, const unsigned int xid); > @@ -108,9 +109,10 @@ extern int SMB2_tcon(const unsigned int xid, struct > cifs_ses *ses, > extern int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon); > extern int SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, >__le16 *path, u64 *persistent_fid, u64 *volatile_fid, > - __u32 desired_access, __u32 create_disposition, > - __u32 file_attributes, __u32 create_options, > - __u8 *oplock, struct smb2_file_all_info *buf); > + __u32 desired_access, __u32 share_access, > + __u32 create_disposition, __u32 file_attributes, > + __u32 create_options, __u8 *oplock, > + struct smb2_file_all_info *buf); > extern int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, > u64 persistent_file_id, u64 volatile_file_id); > extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, -- Jeff Layton

Re: [PATCH v3 2/7] vfs: Add O_DENYREAD/WRITE flags support for open syscall

2013-03-12 Thread Jeff Layton
le_open; > goto out; > } > + /* > + * Lock parent i_mutex to prevent races with deny locks on newely > + * created files. > + */ > + mutex_lock(&dir->d_inode->i_mutex); > + error = deny_lock_file(file); > + mutex_unlock(&dir->d_inode->i_mutex); > + if (error) > + goto exit_fput; > opened: > error = open_check_o_direct(file); > if (error) > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 7617ee0..347e1de 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1005,6 +1005,7 @@ extern int lease_modify(struct file_lock **, int); > extern int lock_may_read(struct inode *, loff_t start, unsigned long count); > extern int lock_may_write(struct inode *, loff_t start, unsigned long count); > extern void locks_delete_block(struct file_lock *waiter); > +extern int deny_lock_file(struct file *); > extern void lock_flocks(void); > extern void unlock_flocks(void); > #else /* !CONFIG_FILE_LOCKING */ > @@ -1153,6 +1154,11 @@ static inline void locks_delete_block(struct file_lock > *waiter) > { > } > > +static inline int deny_lock_file(struct file *filp) > +{ > + return 0; > +} > + > static inline void lock_flocks(void) > { > } -- Jeff Layton

Re: [PATCH v3 5/7] CIFS: Translate SHARING_VIOLATION to -ETXTBSY error code for SMB2

2013-03-12 Thread Jeff Layton
o better reflect the situation. I'd suggest dropping this patch, unless you have a specific need for this error return here. -- Jeff Layton

Re: [PATCH 0/3] Add O_DENY* flags to fcntl and cifs

2012-12-11 Thread Jeff Layton
. The flags are passed to f_ops->flock, but the standard flock routines basically ignore them. Change this by adding enforcement against other LOCK_MAND locks. Also, assume that LOCK_MAND also implies LOCK_NB. Signed-off-by: Jeff Layton --- fs/locks.c | 45 ++-