[PATCH openbmc v6 11/18] initfs: update: check individual mtd partitions for mounts
Andrew Jeffery
andrew at aj.id.au
Mon Jun 27 13:40:50 AEST 2016
On Sun, 2016-06-26 at 00:12 +0000, Milton Miller II wrote:
>
> On 06/23/2016 around 12:35AM in some timezone, Andrew Jeffery wrote:
> >On Wed, 2016-06-22 at 19:30 -0500, OpenBMC Patches wrote:
> >> From: "Milton D. Miller II" <miltonm at us.ibm.com>
> >>
> >> Instead of checking for any mtd device, only check mtd devices
> >> that are to be updated.
> >
> >What do you mean by "instead of"? We're not removing any code here,
> >and
> >from a quick look we loop over the update images in existing checks.
> >
>
> The grep for mtd anywhere in proc at the top of the script (that you
> had me move ERROR up to handle) is replaced with ...
>
> >> Include child mtd devices when looking
> >> for mounted filesystems.
> >>
> >> If this check is suppressed flash updates are suppressed.
> >> Suppressing the check may be useful to verify a update could
> >> succeed at shutdown.
> >>
> >> Signed-off-by: Milton Miller <miltonm at us.ibm.com>
> >> ---
> >> .../obmc-phosphor-initfs/files/obmc-update.sh | 47
> >+++++++++++++++++++---
> >> 1 file changed, 41 insertions(+), 6 deletions(-)
> >>
> >> diff --git
> >a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/ob
> >mc-update.sh
> >b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/ob
> >mc-update.sh
> >> index 4442e5b..22c9dcc 100755
> >> ---
> >a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/ob
> >mc-update.sh
> >> +++
> >b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/ob
> >mc-update.sh
> >> @@ -19,11 +19,34 @@ then
> >> mount -t devtmpfs dev dev
> >> fi
> >>
> >> -if grep mtd /proc/mounts
> >> -then
> >> - echo 1>&2 "ERROR: A mtd device is mounted."
> >> - exit 1
> >> -fi
>
> Right here is the "instead of" code that is being removed.
Ah, thanks, that was an oversight.
>
>
> >> +# mtd number N with mtd name Name can be mounted via mtdN, or
> >mtd:Name
> >> +# (with a mtd aware fs) or by /dev/mtdblockN (with a mtd or block
> >fs).
> >> +mtdismounted() {
> >
> >I keep reading this as mt-dismounted rather than mtd-is-mounted. Can
> >we
> >add some underscores?
>
> If I do that then I have to add them to all the functions and then
> my lines go over 80 characters and then ...
>
> I considered ismtdmounted but that gets back to which is true like
> checkmtdmounted would, so I decided to go with mountedmtd.
>
> >> shift ;;
> >> @@ -135,6 +162,14 @@ do
> >> echo 1>&2 "$E Unable to find mtd partiton for ${f##*/}."
> >> exit 1
> >> fi
> >> + for s in $m $(childmtds $m)
> >> + do
> >> + if test -n "$checkmount" && mtdismounted $s
> >
> >$checkmount is invariant with respect to $s, so is it worth hoisting
> >the check out of the loop? Though it would mean another indent...
> >
>
> Since this also suppresses the call to childmtds I decided to
> implement this, changing the error to be Device $s for ${f} is in use.
>
>
> Unfortunately the file system can be unmounted to where it
> no longer appears in /proc/mounts but is stlil mounted and in
> use by the overlay. I don't know how to fix this.
Right, that's pretty ugly. Though, what context are we running in? I
thought we were executing in initrd, and if so, shouldn't it be
possible to avoid the overlay? That query is based on my hazy
recollection from the initial patches for the update support, so take
it with a grain of salt.
Cheers,
Andrew
> Some long
> ideas are add sysfs status to mtd and add a process holding
> the directory open with the systemd "don't kill leave to shutdown
> script" process name (if that can be done from shell). Or copying
> the .proc/mounts to /run when mounting overlay and checking
> that too. This is to avoid root writing a new image while the
> file system writes to the flash based on the old image, and
> several of these options would not be detect mounting a device
> node with a nonstandard name.
>
> milton
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20160627/d808c834/attachment-0001.sig>
More information about the openbmc
mailing list