From patchwork Fri Apr 5 16:57:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 2399471 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E7A3FDF2E5 for ; Fri, 5 Apr 2013 16:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162048Ab3DEQ4a (ORCPT ); Fri, 5 Apr 2013 12:56:30 -0400 Received: from mail-la0-f51.google.com ([209.85.215.51]:45216 "EHLO mail-la0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162136Ab3DEQyK (ORCPT ); Fri, 5 Apr 2013 12:54:10 -0400 Received: by mail-la0-f51.google.com with SMTP id fo13so3692215lab.38 for ; Fri, 05 Apr 2013 09:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=WnzWNCq8ilOk8YJFmcvhGX3qi9TXN8+f905qSG3EEco=; b=Fj6ykFWsWZR1Svry1wjJ51zvQ80k8HMHqMNfCxNAb4aAWKh+XcGpzcYyZmwlBQB2W6 gjUiz9M1SIKKL+zCwUlp0lAnd36Ml50uTSyIOgaOxHlDHADF6P5E28bouc2OnI8A1JRT 18DHXCwi8iUvc4ITHhx515k1Sgt+ap0ej7b8/qoFkUAey8FIBHULpq88Z46SMjOAZvHy AHzjNG1bgGc18ZphqICjaC0D+mC7H3zSxYQazNUrA1o3gvwe9khz90FGVhzDyNkj0+1X L1bR+R2y9Yg4K8d05n+BUebok9HQyzuQ39q+Z2kW9Zaqq/YEp+lTfJqbXGCx4tNq6QC5 hkRw== X-Received: by 10.112.5.234 with SMTP id v10mr4191069lbv.18.1365180848176; Fri, 05 Apr 2013 09:54:08 -0700 (PDT) Received: from workstation.localdomain ([79.126.74.178]) by mx.google.com with ESMTPS id i3sm5744658lbn.0.2013.04.05.09.54.06 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Apr 2013 09:54:07 -0700 (PDT) From: Pavel Shilovsky 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 v4 3/7] CIFS: Add O_DENY* open flags support Date: Fri, 5 Apr 2013 20:57:51 +0400 Message-Id: <1365181075-22540-4-git-send-email-piastry@etersoft.ru> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1365181075-22540-1-git-send-email-piastry@etersoft.ru> References: <1365181075-22540-1-git-send-email-piastry@etersoft.ru> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Construct share_access value from O_DENY* flags and send it to the server. Signed-off-by: Pavel Shilovsky --- fs/cifs/cifsglob.h | 16 +++++++++++++++- fs/cifs/dir.c | 3 +++ fs/cifs/file.c | 4 ++++ fs/locks.c | 8 ++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index cd4bbf3..7e876b9 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -465,7 +465,7 @@ struct smb_vol { CIFS_MOUNT_CIFS_BACKUPUID | CIFS_MOUNT_CIFS_BACKUPGID) #define CIFS_MS_MASK (MS_RDONLY | MS_MANDLOCK | MS_NOEXEC | MS_NOSUID | \ - MS_NODEV | MS_SYNCHRONOUS) + MS_NODEV | MS_SYNCHRONOUS | MS_SHARELOCK) struct cifs_mnt_data { struct cifs_sb_info *cifs_sb; @@ -947,6 +947,20 @@ struct cifsFileInfo { struct work_struct oplock_break; /* work for oplock breaks */ }; +static inline int +cifs_get_share_flags(unsigned int flags) +{ + int share_access = 0; + + if (!(flags & O_DENYREAD)) + share_access |= FILE_SHARE_READ; + if (!(flags & O_DENYWRITE)) + share_access |= FILE_SHARE_WRITE; + if (!(flags & O_DENYDELETE)) + share_access |= FILE_SHARE_DELETE; + return share_access; +} + struct cifs_io_parms { __u16 netfid; #ifdef CONFIG_CIFS_SMB2 diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 267b608..d4331de 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -294,6 +294,9 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, else cFYI(1, "Create flag not set in create function"); + if (IS_SHARELOCK(inode)) + share_access = cifs_get_share_flags(oflags); + /* * BB add processing to set equivalent of mode - e.g. via CreateX with * ACLs diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 0d524a7..9394b2b 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -210,6 +210,8 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb, *********************************************************************/ disposition = cifs_get_disposition(f_flags); + if (IS_SHARELOCK(inode)) + share_access = cifs_get_share_flags(f_flags); /* BB pass O_SYNC flag through on file attributes .. BB */ @@ -645,6 +647,8 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) } desired_access = cifs_convert_flags(cfile->f_flags); + if (IS_SHARELOCK(inode)) + share_access = cifs_get_share_flags(cfile->f_flags); if (backup_cred(cifs_sb)) create_options |= CREATE_OPEN_BACKUP_INTENT; diff --git a/fs/locks.c b/fs/locks.c index 1eccc75..2184ddd 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -846,10 +846,18 @@ deny_lock_file(struct file *filp) { struct file_lock *lock; int error = 0; + const char *fsname = filp->f_path.dentry->d_inode->i_sb->s_type->name; if (!IS_SHARELOCK(filp->f_path.dentry->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; + error = flock_make_lock(filp, &lock, deny_flags_to_cmd(filp->f_flags)); if (error) return error;