All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Allison Henderson <allison.henderson@oracle.com>,
	linux-xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH 20/21] xfs: Add parent pointer ioctl
Date: Tue, 8 May 2018 13:25:16 +0300	[thread overview]
Message-ID: <CAOQ4uxj1o=XJyb2fDY0K9J0usn2_f39gPeAT0AGakYpH8cqfhg@mail.gmail.com> (raw)
In-Reply-To: <CAOQ4uxh78+xGL24hTCxK-0-tG7Shv83DC7SpDTK3jWmfDusDwA@mail.gmail.com>

On Tue, May 8, 2018 at 1:24 PM, Amir Goldstein <amir73il@gmail.com> wrote:
> On Tue, May 8, 2018 at 12:36 AM, Darrick J. Wong
> <darrick.wong@oracle.com> wrote:
>> On Sun, May 06, 2018 at 10:24:53AM -0700, Allison Henderson wrote:
>>> This patch adds a new file ioctl to retrieve the parent
>>> pointer of a given inode
>>>
>>> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
>>> ---
> [...]
>>> +
>>> +     /*
>>> +      * Now that we know how big the trailing buffer is, expand
>>> +      * our kernel xfs_pptr_info to be the same size
>>> +      */
>>> +     ppi = kmem_realloc(ppi, XFS_PPTR_INFO_SIZEOF(ppi->pi_ptrs_size),
>>
>> Hmm, pi_ptrs_size probably needs some kind of check so that userspace
>> can't ask for insane large allocations.  64k, perhaps?  ~230 records per
>> call ought to be enough for anyone... :P
>>
>> if (XFS_PPTR_INFO_SIZEOFI(...) > XFS_XATTR_LIST_MAX)
>>         return -ENOMEM;
>
> ERANGE feels more appropriate.
>
>> ppi = kmem_realloc(...);
>>
>>> +                          KM_SLEEP);
>>> +     if (!ppi)
>>> +             return -ENOMEM;
>>> +
>>> +     if (ppi->pi_flags == XFS_PPTR_IFLAG_HANDLE) {
>>> +             dentry = xfs_handle_to_dentry(filp, &ppi->pi_handle,
>>> +                                           sizeof(struct xfs_handle));
>>> +             if (IS_ERR(dentry))
>>> +                     return PTR_ERR(dentry);
>>> +             ip = XFS_I(d_inode(dentry));
>>
>> I would've thought that between the dentry and the ip that at least one
>> of those would require a dput/iput, and that we'd need to do something
>> to prevent the dentry or the inode from disappearing from underneath us...
>>
>> ...but you could also extract the inode and generation numbers from the
>> handle information and call xfs_iget directly.  The exportfs code tries
>> to reconnect dentry parent information up to the root, which will turn
>> out badly if some mid-level directory is corrupt and scrub is trying to
>> reconstruct the former path of a now inaccessible file.
>>
>
> Here is an easy code reuse solution for you.
> It's a way to suppress reconnect and reuse of the conversions
> done in xfs_handle_to_dentry().
>
> Thanks,
> Amir.
>
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 89fb1eb80aae..2312862dc34a 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -159,7 +159,8 @@ struct dentry *
>  xfs_handle_to_dentry(
>         struct file             *parfilp,
>         void __user             *uhandle,
> -       u32                     hlen)
> +       u32                     hlen,
> +       bool                    reconnect)
>  {
>         xfs_handle_t            handle;
>         struct xfs_fid64        fid;
> @@ -184,7 +185,7 @@ xfs_handle_to_dentry(
>
>         return exportfs_decode_fh(parfilp->f_path.mnt, (struct fid *)&fid, 3,
>                         FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG,
> -                       xfs_handle_acceptable, NULL);
> +                       reconnect ? xfs_handle_acceptable : NULL, NULL);
>  }
>
>  STATIC struct dentry *
> @@ -192,7 +193,8 @@ xfs_handlereq_to_dentry(
>         struct file             *parfilp,
>         xfs_fsop_handlereq_t    *hreq)
>  {
> -       return xfs_handle_to_dentry(parfilp, hreq->ihandle, hreq->ihandlen);
> +       return xfs_handle_to_dentry(parfilp, hreq->ihandle, hreq->ihandlen,
> +                                   false);

Sorry, that was meant to be true of course. false is what parent pointer ioctl
would use.

Thanks,
Amir.

  reply	other threads:[~2018-05-08 10:25 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-06 17:24 [PATCH 00/21] Parent Pointers v6 Allison Henderson
2018-05-06 17:24 ` [PATCH 01/21] xfs: Move fs/xfs/xfs_attr.h to fs/xfs/libxfs/xfs_attr.h Allison Henderson
2018-05-07 23:39   ` Darrick J. Wong
2018-05-06 17:24 ` [PATCH 02/21] Add trans toggle to attr routines Allison Henderson
2018-05-07 23:52   ` Darrick J. Wong
2018-05-08 17:04     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 03/21] xfs: Add attibute set and helper functions Allison Henderson
2018-05-07 23:36   ` Darrick J. Wong
2018-05-08  7:25     ` Amir Goldstein
2018-05-08 17:02       ` Allison Henderson
2018-05-08 17:01     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 04/21] xfs: Add attibute remove " Allison Henderson
2018-05-07 23:21   ` Darrick J. Wong
2018-05-08  7:33   ` Amir Goldstein
2018-05-08 17:02     ` Allison Henderson
2018-05-08 17:14     ` Darrick J. Wong
2018-05-06 17:24 ` [PATCH 05/21] xfs: Set up infastructure for deferred attribute operations Allison Henderson
2018-05-07 23:19   ` Darrick J. Wong
2018-05-08 17:01     ` Allison Henderson
2018-05-08  9:55   ` Amir Goldstein
2018-05-06 17:24 ` [PATCH 06/21] xfs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred Allison Henderson
2018-05-07 22:59   ` Darrick J. Wong
2018-05-08 17:01     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 07/21] xfs: Remove all strlen calls in all xfs_attr_* functions for attr names Allison Henderson
2018-05-07 22:54   ` Darrick J. Wong
2018-05-08 17:00     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 08/21] xfs: get directory offset when adding directory name Allison Henderson
2018-05-07 22:50   ` Darrick J. Wong
2018-05-06 17:24 ` [PATCH 09/21] xfs: get directory offset when removing " Allison Henderson
2018-05-07 22:48   ` Darrick J. Wong
2018-05-08 17:00     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 10/21] xfs: get directory offset when replacing a " Allison Henderson
2018-05-07 22:45   ` Darrick J. Wong
2018-05-08 17:00     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 11/21] xfs: add parent pointer support to attribute code Allison Henderson
2018-05-07 22:36   ` Darrick J. Wong
2018-05-06 17:24 ` [PATCH 12/21] xfs: define parent pointer xattr format Allison Henderson
2018-05-07 22:35   ` Darrick J. Wong
2018-05-08 17:00     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 13/21] xfs: extent transaction reservations for parent attributes Allison Henderson
2018-05-07 22:34   ` Darrick J. Wong
2018-05-08 17:00     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 14/21] Add lock_flags to xfs_ialloc and xfs_dir_ialloc Allison Henderson
2018-05-07 22:30   ` Darrick J. Wong
2018-05-08 16:59     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 15/21] xfs: parent pointer attribute creation Allison Henderson
2018-05-07 22:19   ` Darrick J. Wong
2018-05-08 16:58     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 16/21] xfs: add parent attributes to link Allison Henderson
2018-05-07 22:12   ` Darrick J. Wong
2018-05-08 16:58     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 17/21] xfs: remove parent pointers in unlink Allison Henderson
2018-05-07 21:59   ` Darrick J. Wong
2018-05-08 16:58     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 18/21] xfs: Add parent pointers to rename Allison Henderson
2018-05-07 21:52   ` Darrick J. Wong
2018-05-08 16:58     ` Allison Henderson
2018-05-08 10:04   ` Amir Goldstein
2018-05-06 17:24 ` [PATCH 19/21] xfs: Add the parent pointer support to the superblock version 5 Allison Henderson
2018-05-07 21:38   ` Darrick J. Wong
2018-05-08 16:58     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 20/21] xfs: Add parent pointer ioctl Allison Henderson
2018-05-07 21:36   ` Darrick J. Wong
2018-05-08 10:24     ` Amir Goldstein
2018-05-08 10:25       ` Amir Goldstein [this message]
2018-05-08 16:57     ` Allison Henderson
2018-05-15 16:27   ` Catalin Iacob
2018-05-15 16:52     ` Allison Henderson
2018-05-06 17:24 ` [PATCH 21/21] xfs: Add delayed attributes error tag Allison Henderson
2018-05-07 20:57   ` Darrick J. Wong
2018-05-08  5:36 ` [PATCH 00/21] Parent Pointers v6 Amir Goldstein
2018-05-08 17:03   ` Allison Henderson

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='CAOQ4uxj1o=XJyb2fDY0K9J0usn2_f39gPeAT0AGakYpH8cqfhg@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=allison.henderson@oracle.com \
    --cc=darrick.wong@oracle.com \
    --cc=linux-xfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.