From: Rakesh Pandit <rakesh@tuxera.com>
To: Benjamin LaHaise <bcrl@kvack.org>
Cc: <viro@zeniv.linux.org.uk>, <linux-fsdevel@vger.kernel.org>,
<linux-aio@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] aio: add aio_migratepage_helper to get rid of duplicate code
Date: Mon, 10 Feb 2014 19:10:45 +0200 [thread overview]
Message-ID: <20140210171045.GA21031@localhost.localdomain> (raw)
In-Reply-To: <20140210162402.GB26657@kvack.org>
On Mon, Feb 10, 2014 at 11:24:02AM -0500, Benjamin LaHaise wrote:
> On Mon, Feb 10, 2014 at 01:52:56PM +0200, Rakesh Pandit wrote:
>
> You're missing a commit message here providing justification for the changes
> submitted. Why is this change a good thing? Did it fix any bugs?
>
It is minor code refactoring to get rid of some duplication of code
inside aio_migratepage. Doesn't fix any issue.
--
Best regards,
Rakesh Pandit
>
> > Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> > ---
> > fs/aio.c | 55 +++++++++++++++++++++++--------------------------------
> > 1 file changed, 23 insertions(+), 32 deletions(-)
> >
> > diff --git a/fs/aio.c b/fs/aio.c
> > index d3d55dc..20d690a 100644
> > --- a/fs/aio.c
> > +++ b/fs/aio.c
> > @@ -278,32 +278,46 @@ static int aio_set_page_dirty(struct page *page)
> > }
> >
> > #if IS_ENABLED(CONFIG_MIGRATION)
> > -static int aio_migratepage(struct address_space *mapping, struct page *new,
> > - struct page *old, enum migrate_mode mode)
> > +static int aio_migratepage_helper(struct address_space *mapping,
> > + struct page *new, struct page *old, bool move)
> > {
> > struct kioctx *ctx;
> > unsigned long flags;
> > - int rc;
> > -
> > - rc = 0;
> > + int rc = 0;
> >
> > - /* Make sure the old page hasn't already been changed */
> > + /* We can potentially race against kioctx teardown here. Use the
> > + * address_space's private data lock to protect the mapping's
> > + * private_data.
> > + */
> > spin_lock(&mapping->private_lock);
> > ctx = mapping->private_data;
> > if (ctx) {
> > pgoff_t idx;
> > spin_lock_irqsave(&ctx->completion_lock, flags);
> > + if (move)
> > + migrate_page_copy(new, old);
> > idx = old->index;
> > if (idx < (pgoff_t)ctx->nr_pages) {
> > if (ctx->ring_pages[idx] != old)
> > rc = -EAGAIN;
> > + else if (move)
> > + ctx->ring_pages[idx] = new;
> > } else
> > rc = -EINVAL;
> > spin_unlock_irqrestore(&ctx->completion_lock, flags);
> > } else
> > - rc = -EINVAL;
> > + rc = move ? -EBUSY : -EINVAL;
> > spin_unlock(&mapping->private_lock);
> > + return rc;
> > +}
> >
> > +static int aio_migratepage(struct address_space *mapping, struct page *new,
> > + struct page *old, enum migrate_mode mode)
> > +{
> > + int rc = 0;
> > +
> > + /* Make sure the old page hasn't already been changed */
> > + rc = aio_migratepage_helper(mapping, new, old, false);
> > if (rc != 0)
> > return rc;
> >
> > @@ -317,31 +331,8 @@ static int aio_migratepage(struct address_space *mapping, struct page *new,
> > return rc;
> > }
> >
> > - /* We can potentially race against kioctx teardown here. Use the
> > - * address_space's private data lock to protect the mapping's
> > - * private_data.
> > - */
> > - spin_lock(&mapping->private_lock);
> > - ctx = mapping->private_data;
> > - if (ctx) {
> > - pgoff_t idx;
> > - spin_lock_irqsave(&ctx->completion_lock, flags);
> > - migrate_page_copy(new, old);
> > - idx = old->index;
> > - if (idx < (pgoff_t)ctx->nr_pages) {
> > - /* And only do the move if things haven't changed */
> > - if (ctx->ring_pages[idx] == old)
> > - ctx->ring_pages[idx] = new;
> > - else
> > - rc = -EAGAIN;
> > - } else
> > - rc = -EINVAL;
> > - spin_unlock_irqrestore(&ctx->completion_lock, flags);
> > - } else
> > - rc = -EBUSY;
> > - spin_unlock(&mapping->private_lock);
> > -
> > - if (rc == MIGRATEPAGE_SUCCESS)
> > + rc = aio_migratepage_helper(mapping, new, old, true);
> > + if (rc == 0)
> > put_page(old);
> > else
> > put_page(new);
> > --
> > 1.8.3.1
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>
WARNING: multiple messages have this Message-ID (diff)
From: Rakesh Pandit <rakesh@tuxera.com>
To: Benjamin LaHaise <bcrl@kvack.org>
Cc: <viro@zeniv.linux.org.uk>, <linux-fsdevel@vger.kernel.org>,
<linux-aio@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] aio: add aio_migratepage_helper to get rid of duplicate code
Date: Mon, 10 Feb 2014 19:10:45 +0200 [thread overview]
Message-ID: <20140210171045.GA21031@localhost.localdomain> (raw)
In-Reply-To: <20140210162402.GB26657@kvack.org>
On Mon, Feb 10, 2014 at 11:24:02AM -0500, Benjamin LaHaise wrote:
> On Mon, Feb 10, 2014 at 01:52:56PM +0200, Rakesh Pandit wrote:
>
> You're missing a commit message here providing justification for the changes
> submitted. Why is this change a good thing? Did it fix any bugs?
>
It is minor code refactoring to get rid of some duplication of code
inside aio_migratepage. Doesn't fix any issue.
--
Best regards,
Rakesh Pandit
>
> > Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> > ---
> > fs/aio.c | 55 +++++++++++++++++++++++--------------------------------
> > 1 file changed, 23 insertions(+), 32 deletions(-)
> >
> > diff --git a/fs/aio.c b/fs/aio.c
> > index d3d55dc..20d690a 100644
> > --- a/fs/aio.c
> > +++ b/fs/aio.c
> > @@ -278,32 +278,46 @@ static int aio_set_page_dirty(struct page *page)
> > }
> >
> > #if IS_ENABLED(CONFIG_MIGRATION)
> > -static int aio_migratepage(struct address_space *mapping, struct page *new,
> > - struct page *old, enum migrate_mode mode)
> > +static int aio_migratepage_helper(struct address_space *mapping,
> > + struct page *new, struct page *old, bool move)
> > {
> > struct kioctx *ctx;
> > unsigned long flags;
> > - int rc;
> > -
> > - rc = 0;
> > + int rc = 0;
> >
> > - /* Make sure the old page hasn't already been changed */
> > + /* We can potentially race against kioctx teardown here. Use the
> > + * address_space's private data lock to protect the mapping's
> > + * private_data.
> > + */
> > spin_lock(&mapping->private_lock);
> > ctx = mapping->private_data;
> > if (ctx) {
> > pgoff_t idx;
> > spin_lock_irqsave(&ctx->completion_lock, flags);
> > + if (move)
> > + migrate_page_copy(new, old);
> > idx = old->index;
> > if (idx < (pgoff_t)ctx->nr_pages) {
> > if (ctx->ring_pages[idx] != old)
> > rc = -EAGAIN;
> > + else if (move)
> > + ctx->ring_pages[idx] = new;
> > } else
> > rc = -EINVAL;
> > spin_unlock_irqrestore(&ctx->completion_lock, flags);
> > } else
> > - rc = -EINVAL;
> > + rc = move ? -EBUSY : -EINVAL;
> > spin_unlock(&mapping->private_lock);
> > + return rc;
> > +}
> >
> > +static int aio_migratepage(struct address_space *mapping, struct page *new,
> > + struct page *old, enum migrate_mode mode)
> > +{
> > + int rc = 0;
> > +
> > + /* Make sure the old page hasn't already been changed */
> > + rc = aio_migratepage_helper(mapping, new, old, false);
> > if (rc != 0)
> > return rc;
> >
> > @@ -317,31 +331,8 @@ static int aio_migratepage(struct address_space *mapping, struct page *new,
> > return rc;
> > }
> >
> > - /* We can potentially race against kioctx teardown here. Use the
> > - * address_space's private data lock to protect the mapping's
> > - * private_data.
> > - */
> > - spin_lock(&mapping->private_lock);
> > - ctx = mapping->private_data;
> > - if (ctx) {
> > - pgoff_t idx;
> > - spin_lock_irqsave(&ctx->completion_lock, flags);
> > - migrate_page_copy(new, old);
> > - idx = old->index;
> > - if (idx < (pgoff_t)ctx->nr_pages) {
> > - /* And only do the move if things haven't changed */
> > - if (ctx->ring_pages[idx] == old)
> > - ctx->ring_pages[idx] = new;
> > - else
> > - rc = -EAGAIN;
> > - } else
> > - rc = -EINVAL;
> > - spin_unlock_irqrestore(&ctx->completion_lock, flags);
> > - } else
> > - rc = -EBUSY;
> > - spin_unlock(&mapping->private_lock);
> > -
> > - if (rc == MIGRATEPAGE_SUCCESS)
> > + rc = aio_migratepage_helper(mapping, new, old, true);
> > + if (rc == 0)
> > put_page(old);
> > else
> > put_page(new);
> > --
> > 1.8.3.1
next prev parent reply other threads:[~2014-02-10 17:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-10 11:52 [PATCH] aio: add aio_migratepage_helper to get rid of duplicate code Rakesh Pandit
2014-02-10 11:52 ` Rakesh Pandit
2014-02-10 16:24 ` Benjamin LaHaise
2014-02-10 16:24 ` Benjamin LaHaise
2014-02-10 17:10 ` Rakesh Pandit [this message]
2014-02-10 17:10 ` Rakesh Pandit
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=20140210171045.GA21031@localhost.localdomain \
--to=rakesh@tuxera.com \
--cc=bcrl@kvack.org \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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.