linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: Jan Kara <jack@suse.cz>
Cc: cluster-devel <cluster-devel@redhat.com>,
	"Christoph Hellwig" <hch@lst.de>,
	"Bob Peterson" <rpeterso@redhat.com>,
	"Dave Chinner" <david@fromorbit.com>,
	"Ross Lagerwall" <ross.lagerwall@citrix.com>,
	"Mark Syms" <Mark.Syms@citrix.com>,
	"Edwin Török" <edvin.torok@citrix.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-mm@kvack.org
Subject: Re: [PATCH v3 1/2] iomap: Add a page_prepare callback
Date: Fri, 26 Apr 2019 15:11:03 +0200	[thread overview]
Message-ID: <CAHc6FU5=g1vzD7iURmcPBEqnQ1WC7GR32r=zzngi+-80mUVv8w@mail.gmail.com> (raw)
In-Reply-To: <20190426083016.GA11637@quack2.suse.cz>

On Fri, 26 Apr 2019 at 10:30, Jan Kara <jack@suse.cz> wrote:
>
> On Thu 25-04-19 18:09:12, Andreas Gruenbacher wrote:
> > Move the page_done callback into a separate iomap_page_ops structure and
> > add a page_prepare calback to be called before a page is written to.  In
> > gfs2, we'll want to start a transaction in page_prepare and end it in
> > page_done, and other filesystems that implement data journaling will
> > require the same kind of mechanism.
>
> ...
>
> > @@ -674,9 +675,17 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
> >       if (fatal_signal_pending(current))
> >               return -EINTR;
> >
> > +     if (page_ops) {
> > +             status = page_ops->page_prepare(inode, pos, len, iomap);
> > +             if (status)
> > +                     return status;
> > +     }
> > +
>
> Looks OK for now I guess, although I'm not sure if later some fs won't need
> to get hold of the actual page in ->page_prepare() and then we will need to
> switch to ->page_prepare() returning the page to use. But let's leave that
> for a time when such fs wants to use iomap.

Alright.

> > @@ -780,8 +794,8 @@ iomap_write_end(struct inode *inode, loff_t pos, unsigned len,
> >               ret = __iomap_write_end(inode, pos, len, copied, page, iomap);
> >       }
> >
> > -     if (iomap->page_done)
> > -             iomap->page_done(inode, pos, copied, page, iomap);
> > +     if (page_ops)
> > +             page_ops->page_done(inode, pos, copied, page, iomap);
>
> Looking at the code now, this is actually flawed (preexisting problem):
> __iomap_write_end or generic_write_end() will release the page reference
> and so you cannot just pass it to ->page_done(). That is a potential
> use-after-free...

Ouch. I'm sending a fix.

Thanks,
Andreas


      reply	other threads:[~2019-04-26 13:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-25 16:09 Andreas Gruenbacher
2019-04-25 16:09 ` [PATCH v3 2/2] gfs2: Fix iomap write page reclaim deadlock Andreas Gruenbacher
2019-04-25 21:01   ` kbuild test robot
2019-04-25 21:01   ` [RFC PATCH] gfs2: gfs2_iomap_page_ops can be static kbuild test robot
2019-04-25 19:09 ` [PATCH v3 1/2] iomap: Add a page_prepare callback kbuild test robot
2019-04-26  8:30 ` Jan Kara
2019-04-26 13:11   ` Andreas Gruenbacher [this message]

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='CAHc6FU5=g1vzD7iURmcPBEqnQ1WC7GR32r=zzngi+-80mUVv8w@mail.gmail.com' \
    --to=agruenba@redhat.com \
    --cc=Mark.Syms@citrix.com \
    --cc=cluster-devel@redhat.com \
    --cc=david@fromorbit.com \
    --cc=edvin.torok@citrix.com \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ross.lagerwall@citrix.com \
    --cc=rpeterso@redhat.com \
    /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