From patchwork Wed May 13 09:09:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 23517 Received: from lists.samba.org (mail.samba.org [66.70.73.150]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4D9ASBK019984 for ; Wed, 13 May 2009 09:10:28 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 57F3E163CC1 for ; Wed, 13 May 2009 09:10:01 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on dp.samba.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.8 tests=AWL, BAYES_00 autolearn=ham version=3.1.7 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) by lists.samba.org (Postfix) with ESMTP id 63202163BE6 for ; Wed, 13 May 2009 09:09:31 +0000 (GMT) Received: from hch by bombadil.infradead.org with local (Exim 4.69 #1 (Red Hat Linux)) id 1M4ATN-0005EU-4M; Wed, 13 May 2009 09:09:57 +0000 Date: Wed, 13 May 2009 05:09:57 -0400 From: Christoph Hellwig To: Jeff Layton Message-ID: <20090513090957.GA9921@infradead.org> References: <1242073472-7100-1-git-send-email-jlayton@redhat.com> <1242073472-7100-4-git-send-email-jlayton@redhat.com> <20090511205620.GC5751@infradead.org> <20090511170348.13b13c25@tleilax.poochiereds.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20090511170348.13b13c25@tleilax.poochiereds.net> User-Agent: Mutt/1.5.18 (2008-05-17) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Cc: linux-fsdevel@vger.kernel.org, linux-cifs-client@lists.samba.org Subject: [linux-cifs-client] Re: [PATCH 03/13] cifs: allow get_cifs_acl to be called without an inode X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Errors-To: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org On Mon, May 11, 2009 at 05:03:48PM -0400, Jeff Layton wrote: > Looks good. I'll plan to incorporate this or something close to it on > the next respin. Here's a similar one for set_cifs_acl: Signed-off-by: Christoph Hellwig Index: linux-2.6/fs/cifs/cifsacl.c =================================================================== --- linux-2.6.orig/fs/cifs/cifsacl.c 2009-05-13 10:58:01.838660889 +0200 +++ linux-2.6/fs/cifs/cifsacl.c 2009-05-13 11:08:42.006785420 +0200 @@ -611,57 +611,61 @@ static struct cifs_ntsd *get_cifs_acl(u3 return pntsd; } -/* Set an ACL on the server */ -static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, - struct inode *inode, const char *path) +static int set_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, __u16 fid, + struct cifs_ntsd *pnntsd, u32 acllen) { - struct cifsFileInfo *open_file; - bool unlock_file = false; - int xid; - int rc = -EIO; - __u16 fid; - struct super_block *sb; - struct cifs_sb_info *cifs_sb; + int xid, rc; - cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); + xid = GetXid(); + rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen); + FreeXid(xid); - if (!inode) - return rc; + cFYI(DBG2, ("SetCIFSACL rc = %d", rc)); + return rc; +} - sb = inode->i_sb; - if (sb == NULL) - return rc; +static int set_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, const char *path, + struct cifs_ntsd *pnntsd, u32 acllen) +{ + int oplock = 0; + int xid, rc; + __u16 fid; - cifs_sb = CIFS_SB(sb); xid = GetXid(); - open_file = find_readable_file(CIFS_I(inode)); - if (open_file) { - unlock_file = true; - fid = open_file->netfid; - } else { - int oplock = 0; - /* open file */ - rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, - WRITE_DAC, 0, &fid, &oplock, NULL, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & - CIFS_MOUNT_MAP_SPECIAL_CHR); - if (rc != 0) { - cERROR(1, ("Unable to open file to set ACL")); - FreeXid(xid); - return rc; - } + rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, WRITE_DAC, 0, + &fid, &oplock, NULL, cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); + if (rc) { + cERROR(1, ("Unable to open file to set ACL")); + goto out; } rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen); cFYI(DBG2, ("SetCIFSACL rc = %d", rc)); - if (unlock_file) - atomic_dec(&open_file->wrtPending); - else - CIFSSMBClose(xid, cifs_sb->tcon, fid); + CIFSSMBClose(xid, cifs_sb->tcon, fid); + out: FreeXid(xid); + return rc; +} + +/* Set an ACL on the server */ +static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, + struct inode *inode, const char *path) +{ + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); + struct cifsFileInfo *open_file; + int rc; + + cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); + + open_file = find_readable_file(CIFS_I(inode)); + if (!open_file) + return set_cifs_acl_by_path(cifs_sb, path, pnntsd, acllen); + rc = set_cifs_acl_by_fid(cifs_sb, open_file->netfid, pnntsd, acllen); + atomic_dec(&open_file->wrtPending); return rc; }