From: Sascha Hauer <s.hauer@pengutronix.de>
To: Markus Pargmann <mpa@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 7/8] ubi: Let ubidetach umount all filesystems before detaching
Date: Mon, 14 Mar 2016 08:32:21 +0100 [thread overview]
Message-ID: <20160314073221.GP30994@pengutronix.de> (raw)
In-Reply-To: <1457598600-10669-7-git-send-email-mpa@pengutronix.de>
On Thu, Mar 10, 2016 at 09:29:59AM +0100, Markus Pargmann wrote:
> This patch iterates through all ubi volumes and umounts all filesystems
> that are mounted.
>
> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> ---
> drivers/mtd/ubi/build.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 7ee34bc62f30..edaa98b0973c 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -25,6 +25,7 @@
> * later using the "UBI control device".
> */
>
> +#include <fs.h>
> #include <linux/err.h>
> #include <linux/stringify.h>
> #include <linux/stat.h>
> @@ -713,6 +714,8 @@ out_free:
> int ubi_detach_mtd_dev(int ubi_num, int anyway)
> {
> struct ubi_device *ubi;
> + int vol_id;
> + int ret;
>
> if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES)
> return -EINVAL;
> @@ -723,6 +726,32 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
>
> ubi->ref_count--;
>
> + ubi_volume_for_each(ubi_num, ubi, vol_id, ret) {
> + struct ubi_volume_desc *vol;
> +
> + vol = ubi_open_volume(ubi_num, vol_id, UBI_READONLY);
> + if (IS_ERR(vol)) {
> + pr_err("Failed to open ubi volume %d %d, %ld\n",
> + ubi_num, vol_id, PTR_ERR(vol));
> + if (anyway)
> + continue;
> +
> + ubi_volume_abort(ubi);
> + return PTR_ERR(vol);
> + }
> +
> + ret = umount_by_cdev(ubi_volume_get_cdev(vol));
> + ubi_close_volume(vol);
> + if (ret) {
> + pr_err("Failed umounting ubi volume %d %d, %d\n",
> + ubi_num, vol_id, ret);
> + if (anyway)
> + continue;
> + ubi_volume_abort(ubi);
> + return ret;
> + }
> + }
Wouldn't the following do it?
void ubi_umount_volumes(struct ubi_device *ubi)
{
int i;
for (i = 0; i < ubi->vtbl_slots; i++) {
struct ubi_volume *vol = ubi->volumes[i];
if (!vol)
continue;
umount_by_cdev(vol->cdev);
}
}
We shouldn't change the UBI code too much as it makes updates harder. If
possible, please move the code to cdev.c which is completely barebox
specific (if needed, we may rename cdev.c to barebox.c)
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2016-03-14 7:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-10 8:29 [PATCH v2 1/8] fs: Add for_each_fs_device_safe() Markus Pargmann
2016-03-10 8:29 ` [PATCH v2 2/8] fs: umount based on device path and mount path Markus Pargmann
2016-03-10 8:29 ` [PATCH v2 3/8] ubi: Add getter ubi_volume_get_cdev() Markus Pargmann
2016-03-10 8:29 ` [PATCH v2 4/8] ubi: Add helper to map a mtd device to a ubi number Markus Pargmann
2016-03-10 8:29 ` [PATCH v2 5/8] ubi: Helper to iterate over all ubi volumes Markus Pargmann
2016-03-10 8:29 ` [PATCH v2 6/8] ubi: Add function to detach a UBI by using mtd_info Markus Pargmann
2016-03-10 8:29 ` [PATCH v2 7/8] ubi: Let ubidetach umount all filesystems before detaching Markus Pargmann
2016-03-14 7:32 ` Sascha Hauer [this message]
2016-03-10 8:30 ` [PATCH v2 8/8] ubiformat: Cleanly umount and detach the ubi before formating Markus Pargmann
2016-03-14 7:41 ` Sascha Hauer
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=20160314073221.GP30994@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=mpa@pengutronix.de \
/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