From: chengzhihao <chengzhihao1@huawei.com>
To: "david.oberhollenzer@sigma-star.at"
<david.oberhollenzer@sigma-star.at>,
"richard@nod.at" <richard@nod.at>,
"david@sigma-star.at" <david@sigma-star.at>,
"boris.brezillon@free-electrons.com"
<boris.brezillon@free-electrons.com>,
"zhangyi (F)" <yi.zhang@huawei.com>
Cc: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: 答复: [PATCH RFC v2] mtd: ubi: Add fastmap sysfs attribute
Date: Wed, 3 Jul 2019 01:25:28 +0000 [thread overview]
Message-ID: <0B80F9D4116B2F4484E7279D5A66984F793E33@dggemi524-mbx.china.huawei.com> (raw)
In-Reply-To: <1561723581-70340-1-git-send-email-chengzhihao1@huawei.com>
ping ~
-----邮件原件-----
发件人: chengzhihao
发送时间: 2019年6月28日 20:06
收件人: david.oberhollenzer@sigma-star.at; richard@nod.at; david@sigma-star.at; boris.brezillon@free-electrons.com; zhangyi (F) <yi.zhang@huawei.com>
抄送: linux-mtd@lists.infradead.org; linux-kernel@vger.kernel.org; chengzhihao <chengzhihao1@huawei.com>
主题: [PATCH RFC v2] mtd: ubi: Add fastmap sysfs attribute
The UBI device can be attached to a MTD device via fastmap by setting CONFIG_MTD_UBI_FASTMAP to 'y' (If there already exists a fastmap on the UBI device). To support some debugging scenarios, attaching process by fastmap can be confirmed in dmesg. If the UBI device is attached by fastmap, logs like following will appear in dmesg:
ubi0: attached by fastmap
If multiple UBI devices are attached to multiple MTD devices at the same time, how to distinguish which UBI devices are successfully attached by fastmap? Extracting attaching information for each UBI device one by one from dmesg is a way. A better method is to record fastmap existence in sysfs, so it can be obtained by userspace tools.
This patch exposes fastmap on sysfs. Suppose you attach an UBI device to a MTD device by fastmap: if fastmap equals to '1', that is, the fastmap generated before last detaching operation is confirmed valid. Else, there may be some problems with old fastmap. Besides, userspace tool can also check whether the fastmap updating triggered by other operations (such as resize volume) is successful by reading this sysfs attribute.
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
Documentation/ABI/stable/sysfs-class-ubi | 15 +++++++++++++++
drivers/mtd/ubi/build.c | 9 ++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/stable/sysfs-class-ubi b/Documentation/ABI/stable/sysfs-class-ubi
index a6b3240..1d96cf0 100644
--- a/Documentation/ABI/stable/sysfs-class-ubi
+++ b/Documentation/ABI/stable/sysfs-class-ubi
@@ -116,6 +116,21 @@ Description:
device, and "0\n" if it is cleared. UBI devices mark themselves
as read-only when they detect an unrecoverable error.
+What: /sys/class/ubi/ubiX/fastmap
+Date: June 2019
+KernelVersion: 5.2
+Contact: linux-mtd@lists.infradead.org
+Description:
+ Contains ASCII "1\n" if there exists a fastmap on UBI device,
+ and "0\n" if there not exists a fastmap on UBI device. After
+ attaching the UBI device to a MTD device via fastmap, userspace
+ tool can sense that there is a fastmap on UBI device by
+ checking sysfs attribute 'fastmap', that is, the fastmap
+ generated before last detaching operation is valid. In addition,
+ userspace tool can also check whether the fastmap updating
+ triggered by volume operation is successful by reading this
+ sysfs attribute.
+
What: /sys/class/ubi/ubiX/total_eraseblocks
Date: July 2006
KernelVersion: 2.6.22
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index d636bbe..0cd6b8e 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -140,6 +140,8 @@ static struct device_attribute dev_mtd_num =
__ATTR(mtd_num, S_IRUGO, dev_attribute_show, NULL); static struct device_attribute dev_ro_mode =
__ATTR(ro_mode, S_IRUGO, dev_attribute_show, NULL);
+static struct device_attribute dev_fastmap =
+ __ATTR(fastmap, S_IRUGO, dev_attribute_show, NULL);
/**
* ubi_volume_notify - send a volume change notification.
@@ -378,7 +380,11 @@ static ssize_t dev_attribute_show(struct device *dev,
ret = sprintf(buf, "%d\n", ubi->mtd->index);
else if (attr == &dev_ro_mode)
ret = sprintf(buf, "%d\n", ubi->ro_mode);
- else
+ else if (attr == &dev_fastmap) {
+ down_write(&ubi->fm_protect);
+ ret = sprintf(buf, "%d\n", ubi->fm ? 1 : 0);
+ up_write(&ubi->fm_protect);
+ } else
ret = -EINVAL;
ubi_put_device(ubi);
@@ -398,6 +404,7 @@ static struct attribute *ubi_dev_attrs[] = {
&dev_bgt_enabled.attr,
&dev_mtd_num.attr,
&dev_ro_mode.attr,
+ &dev_fastmap.attr,
NULL
};
ATTRIBUTE_GROUPS(ubi_dev);
--
2.7.4
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2019-07-03 1:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-28 12:06 [PATCH RFC v2] mtd: ubi: Add fastmap sysfs attribute Zhihao Cheng
2019-07-03 1:25 ` chengzhihao [this message]
2019-07-12 21:54 ` Richard Weinberger
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=0B80F9D4116B2F4484E7279D5A66984F793E33@dggemi524-mbx.china.huawei.com \
--to=chengzhihao1@huawei.com \
--cc=boris.brezillon@free-electrons.com \
--cc=david.oberhollenzer@sigma-star.at \
--cc=david@sigma-star.at \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=yi.zhang@huawei.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).