mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Markus Pargmann <mpa@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 5/5] ubiformat: Cleanly umount and detach the ubi before formating
Date: Wed, 9 Mar 2016 08:55:13 +0100	[thread overview]
Message-ID: <20160309075513.GD30994@pengutronix.de> (raw)
In-Reply-To: <1457434569-32054-5-git-send-email-mpa@pengutronix.de>

Hi Markus,

On Tue, Mar 08, 2016 at 11:56:09AM +0100, Markus Pargmann wrote:
> This was an open fixme for some time. ubiformat does not care about used
> ubi volumes or attached ubis.
> 
> This patch adds functionality that umounts all filesystems that are
> mounted from this nand device. After that the ubi is detached. Then the
> normal ubiformat code reformats the ubi. If a ubi was detached
> previously, the code tries to reattach the ubi. Filesystems are not
> remounted.

Normally I would expect ubiformat to fail when the mtd is used by UBI.
Can we make the behaviour optional and by default fail if the mtd is
busy?

> +static int ubi_umount_all(const char *mtddev, struct mtd_info_user *ui,
> +			  int *ubi_detached_num)
> +{
> +	struct ubi_device_info ubi_info;
> +	struct cdev *ubi_cdev;
> +	struct fs_device_d *fsdev;
> +	struct fs_device_d *fsdev_tmp;
> +	struct ubi_device *ubi_dev;
> +	int ret;
> +	int ubi_num;
> +	int vol_id;
> +
> +
> +	ubi_num = ubi_num_get_by_mtd(ui->mtd);
> +	if (ubi_num < 0) /* No attached ubi found */
> +		return 0;
> +
> +	ubi_get_device_info(ubi_num, &ubi_info);
> +
> +	ubi_volume_for_each(ubi_num, ubi_dev, 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. Continuing\n",
> +			       ubi_num, vol_id, PTR_ERR(vol));
> +			continue;
> +		}
> +
> +		for_each_fs_device_safe(fsdev_tmp, fsdev) {
> +			ubi_cdev = ubi_volume_get_cdev(vol);
> +
> +			if (fsdev->cdev == ubi_volume_get_cdev(vol)) {
> +				ret = umount(fsdev->path);
> +				if (ret) {
> +					pr_err("Failed umounting %s, %d, continuing anyway\n",
> +					       fsdev->path, ret);
> +				}

Shouldn't this be an error?

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

      reply	other threads:[~2016-03-09  7:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08 10:56 [PATCH 1/5] fs: Add for_each_fs_device_safe() Markus Pargmann
2016-03-08 10:56 ` [PATCH 2/5] ubi: Add getter ubi_volume_get_cdev() Markus Pargmann
2016-03-08 10:56 ` [PATCH 3/5] ubi: Add helper to map a mtd device to a ubi number Markus Pargmann
2016-03-08 10:56 ` [PATCH 4/5] ubi: Helper to iterate over all ubi volumes Markus Pargmann
2016-03-08 10:56 ` [PATCH 5/5] ubiformat: Cleanly umount and detach the ubi before formating Markus Pargmann
2016-03-09  7:55   ` Sascha Hauer [this message]

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=20160309075513.GD30994@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