linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
To: Jeff Layton <jlayton@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-cifs-client@lists.samba.org
Subject: Re: [linux-cifs-client] [PATCH 04/13] cifs: clean up set_cifs_acl interfaces
Date: Thu, 14 May 2009 07:38:39 -0500	[thread overview]
Message-ID: <4a4634330905140538i61ec6ca1i9c6fec2003544fd5@mail.gmail.com> (raw)
In-Reply-To: <20090514082119.2023aa6f@tleilax.poochiereds.net>

On Thu, May 14, 2009 at 7:21 AM, Jeff Layton <jlayton@redhat.com> wrote:
> On Wed, 13 May 2009 21:53:13 -0500
> Shirish Pargaonkar <shirishpargaonkar@gmail.com> wrote:
>
>> On Wed, May 13, 2009 at 3:04 PM, Jeff Layton <jlayton@redhat.com> wrote:
>> > From: Christoph Hellwig <hch@infradead.org>
>> >
>> > Signed-off-by: Christoph Hellwig <hch@lst.de>
>> > Signed-off-by: Jeff Layton <jlayton@redhat.com>
>> > ---
>> >  fs/cifs/cifsacl.c |   78 ++++++++++++++++++++++++++++-------------------------
>> >  1 files changed, 41 insertions(+), 37 deletions(-)
>> >
>> > diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
>> > index 7f8e6c4..1403b5d 100644
>> > --- a/fs/cifs/cifsacl.c
>> > +++ b/fs/cifs/cifsacl.c
>> > @@ -612,57 +612,61 @@ static struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
>> >        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));
>>
>> We do not know how the file was opened or whether one can set the
>> attributes just
>> because we have a file handle.
>> So there is a possibility that set_cifs_acl_by_fid can fail but
>> set_cifs_acl_by_path
>> will succeed by virtue of opening file with attribute FILE_OPEN, WRITE_DAC?
>>
>
> You're correct that that does seem wrong, but I don't think this patch
> makes that any worse than it already is. The current set_cifs_acl code
> does a find_readable_file, and uses that fid to try and set the ACL.
>

Jeff, you are right.

> On a side note, this whole find_readable_file/find_writeable_file
> interface is a real mess. What we really need I think is a new
> find_open_file function that takes a set of open flags as an arg. When
> it finds an open fh with flags that match the ones you've requested, it
> can return that with the refcount bumped.
>
> In fact, it would be even better if all of the "fallback to doing a new
> open" stuff was hidden in an interface too so that callers didn't have
> to worry about it.
>
>> > +       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;
>> >  }
>> >
>> > --
>> > 1.6.2.2
>> >
>
>
> --
> Jeff Layton <jlayton@redhat.com>
>

  reply	other threads:[~2009-05-14 12:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-13 20:04 [PATCH 00/13] cifs: implement proper hardlink detection (try #3) Jeff Layton
2009-05-13 20:04 ` [PATCH 01/13] cifs: have cifs_NTtimeToUnix take a little-endian arg Jeff Layton
2009-05-19 14:06   ` Christoph Hellwig
2009-05-13 20:04 ` [PATCH 02/13] cifs: make cnvrtDosUnixTm take a little-endian args and an offset Jeff Layton
2009-05-19 14:06   ` Christoph Hellwig
2009-05-13 20:04 ` [PATCH 03/13] cifs: reorganize get_cifs_acl Jeff Layton
2009-05-13 20:04 ` [PATCH 04/13] cifs: clean up set_cifs_acl interfaces Jeff Layton
2009-05-14  2:53   ` [linux-cifs-client] " Shirish Pargaonkar
2009-05-14 12:21     ` Jeff Layton
2009-05-14 12:38       ` Shirish Pargaonkar [this message]
2009-05-13 20:04 ` [PATCH 05/13] cifs: rename cifs_iget to cifs_root_iget Jeff Layton
2009-05-19 14:08   ` [linux-cifs-client] " Christoph Hellwig
2009-05-13 20:04 ` [PATCH 06/13] cifs: add new cifs_iget function and convert unix codepath to use it Jeff Layton
2009-05-13 20:04 ` [PATCH 07/13] cifs: convert posix readdir codepath to use cifs_iget Jeff Layton
2009-05-13 20:04 ` [PATCH 08/13] cifs: convert cifs_get_inode_info " Jeff Layton
2009-05-13 20:04 ` [PATCH 09/13] cifs: convert non-posix readdir codepath " Jeff Layton
2009-05-13 20:04 ` [PATCH 10/13] cifs: remove cifs_new_inode Jeff Layton
2009-05-13 20:04 ` [PATCH 11/13] cifs: make serverino the default when mounting Jeff Layton
2009-05-13 20:04 ` [PATCH 12/13] cifs: remove cifsInodeInfo->inUse counter Jeff Layton
2009-05-13 20:04 ` [PATCH 13/13] cifs: remove "hardlink detection" from cifs_rename Jeff Layton

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=4a4634330905140538i61ec6ca1i9c6fec2003544fd5@mail.gmail.com \
    --to=shirishpargaonkar@gmail.com \
    --cc=jlayton@redhat.com \
    --cc=linux-cifs-client@lists.samba.org \
    --cc=linux-fsdevel@vger.kernel.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).