From: Adrian Huang12 <ahuang12@lenovo.com>
To: Jan Kara <jack@suse.cz>, Adrian Huang <adrianhuang0701@gmail.com>
Cc: "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>,
Coly Li <colyli@suse.de>, Mikulas Patocka <mpatocka@redhat.com>,
Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@redhat.com>
Subject: RE: [External] Re: [PATCH 1/1] dax: Fix stack overflow when mounting fsdax pmem device
Date: Wed, 16 Sep 2020 07:02:12 +0000 [thread overview]
Message-ID: <HK2PR0302MB25945D758119BECF62C7DC73B3210@HK2PR0302MB2594.apcprd03.prod.outlook.com> (raw)
In-Reply-To: <20200915083716.GA29863@quack2.suse.cz>
> -----Original Message-----
> From: Jan Kara <jack@suse.cz>
>
> I'm not sure how you can get __generic_fsdax_supported() called for dm-0?
> Possibly because there's another dm device stacked on top of it and
> dm_table_supports_dax() calls generic_fsdax_supported()? That actually seems
> to be a bug in dm_table_supports_dax() (device_supports_dax() in particular).
> I'd think it should be calling dax_supported() instead of
> generic_fsdax_supported() so that proper device callback gets called when
> determining whether a device supports DAX or not.
>
Yes, you're right. There's another dm device stacked on top of it.
When applying the following patch and running 'lvm2-testsuite --only activate-minor.sh', the following error messages are observed.
dm-3: error: dax access failed (-95)
dm-3: error: dax access failed (-95)
dm-3: error: dax access failed (-95)
The commands 'lvchange $vg/foo -My --major=255 --minor=123' and 'lvchange $vg/foo -a y' in activate-minor.sh (https://fossies.org/linux/LVM2/test/shell/activate-minor.sh) create another dm device (dm-123) on top of dm-3. Please see the following command output.
# ls -l /dev/mapper
total 0
lrwxrwxrwx. 1 root root 7 Sep 16 02:12 LVMTEST14781pv1 -> ../dm-3
lrwxrwxrwx. 1 root root 9 Sep 16 02:12 LVMTEST14781vg-foo -> ../dm-123
crw-------. 1 root root 10, 236 Sep 16 01:41 control
lrwxrwxrwx. 1 root root 7 Sep 16 01:41 rhel-home -> ../dm-2
lrwxrwxrwx. 1 root root 7 Sep 16 01:41 rhel-root -> ../dm-0
lrwxrwxrwx. 1 root root 7 Sep 16 01:41 rhel-swap -> ../dm-1
# ls -l /dev/dm*
brw-rw----. 1 root disk 253, 0 Sep 16 01:41 /dev/dm-0
brw-rw----. 1 root disk 253, 1 Sep 16 01:41 /dev/dm-1
brw-rw----. 1 root disk 253, 123 Sep 16 02:12 /dev/dm-123
brw-rw----. 1 root disk 253, 2 Sep 16 01:41 /dev/dm-2
brw-rw----. 1 root disk 253, 3 Sep 16 02:12 /dev/dm-3
# dmsetup table
rhel-home: 0 344326144 linear 8:19 16345088
LVMTEST14781vg-foo: 0 1024 linear 253:3 2048
rhel-swap: 0 16343040 linear 8:19 2048
rhel-root: 0 104857600 linear 8:19 360671232
LVMTEST14781pv1: 0 69632 linear 1:0 0
I also use trace-cmd tool (command: trace-cmd record -p function -l '*dax*' -l '*dm_*' -l 'linear_*') to record the whole call path:
dm_get_md_type
dm_table_supports_dax
linear_iterate_devices
device_supports_dax
__generic_fsdax_supported (dax_dev is valid for dm-3)
dm_dax_direct_access
dax_get_private
dm_dax_get_live_target
dm_table_find_target
linear_dax_direct_access
bdev_dax_pgoff
dax_direct_access (dax_dev is NULL for physical device. Return -EOPNOTSUPP)
dm_dax_direct_access
dax_get_private
dm_dax_get_live_target
dm_table_find_target
linear_dax_direct_access
bdev_dax_pgoff
dax_direct_access (dax_dev is NULL for physical device. Return -EOPNOTSUPP)
Please find the attachment for the full log. You can see three dm_table_supports_dax() calls in the attachment, which aligns with the dmesg output (three dax error messages).
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index e5767c83ea23..11d0541e6f8f 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -85,6 +85,12 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
return false;
}
+ if (!dax_dev) {
+ pr_debug("%s: error: dax unsupported by block device\n",
+ bdevname(bdev, buf));
+ return false;
+ }
+
err = bdev_dax_pgoff(bdev, start, PAGE_SIZE, &pgoff);
if (err) {
pr_info("%s: error: unaligned partition for dax\n",
@@ -100,12 +106,6 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
return false;
}
- if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {
- pr_debug("%s: error: dax unsupported by block device\n",
- bdevname(bdev, buf));
- return false;
- }
-
id = dax_read_lock();
len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn);
len2 = dax_direct_access(dax_dev, pgoff_end, 1, &end_kaddr, &end_pfn);
-- Adrian
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
next prev parent reply other threads:[~2020-09-16 7:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-15 7:57 [PATCH 1/1] dax: Fix stack overflow when mounting fsdax pmem device Adrian Huang
2020-09-15 8:37 ` Jan Kara
2020-09-16 7:02 ` Adrian Huang12 [this message]
2020-09-16 11:19 ` [External] " Jan Kara
2020-09-16 14:02 ` Adrian Huang12
2020-09-16 15:08 ` Jan Kara
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=HK2PR0302MB25945D758119BECF62C7DC73B3210@HK2PR0302MB2594.apcprd03.prod.outlook.com \
--to=ahuang12@lenovo.com \
--cc=adrianhuang0701@gmail.com \
--cc=agk@redhat.com \
--cc=colyli@suse.de \
--cc=jack@suse.cz \
--cc=linux-nvdimm@lists.01.org \
--cc=mpatocka@redhat.com \
--cc=snitzer@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;
as well as URLs for NNTP newsgroup(s).