From: Andrew Morton <akpm@linux-foundation.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: Shiyang Ruan <ruansy.fnst@fujitsu.com>,
linux-xfs@vger.kernel.org, nvdimm@lists.linux.dev,
linux-fsdevel@vger.kernel.org, djwong@kernel.org,
david@fromorbit.com, dan.j.williams@intel.com
Subject: Re: [PATCH] fsdax: dax_unshare_iter() should return a valid length
Date: Thu, 2 Feb 2023 16:23:48 -0800 [thread overview]
Message-ID: <20230202162348.f90fea5cbff377b977f7b6b1@linux-foundation.org> (raw)
In-Reply-To: <Y9xAw+poZxOyMk1J@casper.infradead.org>
On Thu, 2 Feb 2023 23:01:23 +0000 Matthew Wilcox <willy@infradead.org> wrote:
> On Thu, Feb 02, 2023 at 12:33:47PM +0000, Shiyang Ruan wrote:
> > The copy_mc_to_kernel() will return 0 if it executed successfully.
> > Then the return value should be set to the length it copied.
> >
> > Fixes: d984648e428b ("fsdax,xfs: port unshare to fsdax")
> > Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
> > ---
> > fs/dax.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/fs/dax.c b/fs/dax.c
> > index c48a3a93ab29..a5b4deb5def3 100644
> > --- a/fs/dax.c
> > +++ b/fs/dax.c
> > @@ -1274,6 +1274,7 @@ static s64 dax_unshare_iter(struct iomap_iter *iter)
> > ret = copy_mc_to_kernel(daddr, saddr, length);
> > if (ret)
> > ret = -EIO;
> > + ret = length;
>
> Umm. Surely should be:
>
> else
> ret = length;
>
> otherwise you've just overwritten the -EIO.
yup
> And maybe this should be:
>
> ret = length - copy_mc_to_kernel(daddr, saddr, length);
> if (ret < length)
> ret = -EIO;
>
not a fan of giving `ret' a temporary new meaning like that. If it was
copied = length - copy_mc_to_kernel(daddr, saddr, length);
if (copied < length)
ret = -EIO;
then it would be clear.
Clearer, methinks:
if (copy_mc_to_kernel(daddr, saddr, length) == 0)
ret = length;
else
ret = -EIO;
next prev parent reply other threads:[~2023-02-03 0:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 12:33 [PATCH] fsdax: dax_unshare_iter() should return a valid length Shiyang Ruan
2023-02-02 23:01 ` Matthew Wilcox
2023-02-03 0:23 ` Andrew Morton [this message]
2023-02-03 0:42 ` Dan Williams
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=20230202162348.f90fea5cbff377b977f7b6b1@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=ruansy.fnst@fujitsu.com \
--cc=willy@infradead.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).