linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "idryomov@gmail.com" <idryomov@gmail.com>,
	"slava@dubeyko.com" <slava@dubeyko.com>
Cc: "ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	Alex Markuze <amarkuze@redhat.com>,
	David Howells <dhowells@redhat.com>
Subject: RE: [PATCH v2] ceph: Fix kernel crash in generic/397 test
Date: Fri, 17 Jan 2025 19:18:03 +0000	[thread overview]
Message-ID: <9e8549979a832b345cb2193cc0eede6b350a4981.camel@ibm.com> (raw)
In-Reply-To: <CAOi1vP97xPyka60H=bMh3xyOtumO+WQfMYF8NG0V545oYnQG7Q@mail.gmail.com>

Hi Ilya,

On Fri, 2025-01-17 at 13:06 +0100, Ilya Dryomov wrote:
> On Fri, Jan 17, 2025 at 4:51 AM Viacheslav Dubeyko <slava@dubeyko.com> wrote:
> > 
> > 

<skipped>

> > Signed-off-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
> > ---
> >  fs/ceph/addr.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> > index 85936f6d2bf7..5e6ba92219f3 100644
> > --- a/fs/ceph/addr.c
> > +++ b/fs/ceph/addr.c
> > @@ -396,6 +396,15 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq)
> >                 struct page **pages;
> >                 size_t page_off;
> > 
> > +               /*
> > +                * The io_iter.count needs to be corrected to aligned length.
> > +                * Otherwise, iov_iter_get_pages_alloc2() operates with
> > +                * the initial unaligned length value. As a result,
> > +                * ceph_msg_data_cursor_init() triggers BUG_ON() in the case
> > +                * if msg->sparse_read_total > msg->data_length.
> > +                */
> > +               subreq->io_iter.count = len;
> 
> Hi Slava,
> 
> So I take it that my hunch that it's subreq->io_iter and commenting out
> "len = err" assignment worked?  TBH munging the count this way feels as
> much of an ugly workaround as ignoring iov_iter_get_pages_alloc2()
> return value (unless it's an error) to me.
> 

As far as I can see, the main issue that subreq->io_iter keeps
unaligned value in subreq->io_iter.count. And if the alignment
was made earlier [1]:

	len = subreq->len;
	ceph_fscrypt_adjust_off_and_len(inode, &off, &len);

then it needs to correct the value of subreq->io_iter.count later
before calling iov_iter_get_pages_alloc2() [2]:

	if (IS_ENCRYPTED(inode)) {
		struct page **pages;
		size_t page_off;

		err = iov_iter_get_pages_alloc2(&subreq->io_iter, &pages, len, &page_off);
		if (err < 0) {
			doutc(cl, "%llx.%llx failed to allocate pages, %d\n",
			      ceph_vinop(inode), err);
			goto out;
		}

		/* should always give us a page-aligned read */
		WARN_ON_ONCE(page_off);
		len = err;
		err = 0;

		osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0, false,
						 false);
	}

or ceph_netfs_issue_read() needs to be called with already
aligned value of subreq->io_iter.count.

If we have correct value (aligned) of subreq->io_iter.count, then
it doesn't matter "len = err" commented or not.

> Since this confirms that we have a regression introduced in ee4cdf7ba857
> ("netfs: Speed up buffered reading"), let's wait for David to chime in.
> 

Sounds good!

Thanks,
Slava.

[1] https://elixir.bootlin.com/linux/v6.13-rc3/source/fs/ceph/addr.c#L365
[2] https://elixir.bootlin.com/linux/v6.13-rc3/source/fs/ceph/addr.c#L395



  reply	other threads:[~2025-01-17 19:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-17  3:50 [PATCH v2] ceph: Fix kernel crash in generic/397 test Viacheslav Dubeyko
2025-01-17 12:06 ` Ilya Dryomov
2025-01-17 19:18   ` Viacheslav Dubeyko [this message]
2025-01-17 21:32 ` David Howells
2025-01-17 22:08   ` Viacheslav Dubeyko
2025-01-20  9:33 ` David Howells
2025-01-20  9:47   ` Alex Markuze
2025-01-27 18:40     ` Viacheslav Dubeyko
2025-01-28 16:13     ` David Howells
2025-01-28 16:57     ` David Howells
2025-01-28 20:01     ` David Howells
2025-01-28 20:16       ` Viacheslav Dubeyko
2025-01-28 22:34       ` David Howells
2025-01-28 22:37         ` Viacheslav Dubeyko
2025-01-29 10:39           ` Alex Markuze
2025-01-29 13:42           ` David Howells
2025-01-29 13:54             ` Alex Markuze
2025-01-29 13:41         ` David Howells
2025-01-29 19:16           ` Viacheslav Dubeyko
2025-02-14 20:29 ` David Howells
2025-02-14 20:54   ` Viacheslav Dubeyko
2025-04-15 17:59 ` Viacheslav Dubeyko
2025-06-01 16:23   ` Ilya Dryomov

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=9e8549979a832b345cb2193cc0eede6b350a4981.camel@ibm.com \
    --to=slava.dubeyko@ibm.com \
    --cc=amarkuze@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dhowells@redhat.com \
    --cc=idryomov@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=slava@dubeyko.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;
as well as URLs for NNTP newsgroup(s).