All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rootfs-block: avoid remount when options don't change
@ 2012-04-11 22:00 Daniel Drake
       [not found] ` <20120411220043.883609D401E-k/4jFdqg8LLlyo9zxV8I99HuzzzSOjJt@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Drake @ 2012-04-11 22:00 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Mounting, unmounting and then mounting a disk partition takes some
time.

On embedded systems such as OLPC XO where we disable fsck and fstab
reading, the root options are not going to change throughout the
mount_root() function, so remounting is time consuming and without
change.

Detect and optimize for this case so that the filesystem is only
mounted once.
---
 modules.d/95rootfs-block/mount-root.sh |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/modules.d/95rootfs-block/mount-root.sh b/modules.d/95rootfs-block/mount-root.sh
index 2c89431..aef99ae 100755
--- a/modules.d/95rootfs-block/mount-root.sh
+++ b/modules.d/95rootfs-block/mount-root.sh
@@ -98,20 +98,24 @@ mount_root() {
     # them; rflags is guaranteed to not be empty
     rflags="${rootopts:+"${rootopts},"}${rflags}"
 
-    umount "$NEWROOT"
-
     # backslashes are treated as escape character in fstab
     # esc_root=$(echo ${root#block:} | sed 's,\\,\\\\,g')
     # printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab
 
+    ran_fsck=0
     if [ -z "$fastboot" -a "$READONLY" != "yes" ] && ! strstr "${rflags},${rootopts}" _netdev; then
+        umount "$NEWROOT"
         fsck_single "${root#block:}" "$rootfs" "$fsckoptions"
         _ret=$?
         [ $_ret -ne 255 ] && echo $_ret >/run/initramfs/root-fsck
+        ran_fsck=1
     fi
 
-    info "Remounting ${root#block:} with -o ${rflags}"
-    mount -t "$rootfs" -o "$rflags" "${root#block:}" "$NEWROOT" 2>&1 | vinfo
+    if [ -n "$rootopts" -o "$ran_fsck" = "1" ]; then
+        info "Remounting ${root#block:} with -o ${rflags}"
+        umount "$NEWROOT" &>/dev/null
+        mount -t "$rootfs" -o "$rflags" "${root#block:}" "$NEWROOT" 2>&1 | vinfo
+    fi
 
     [ -f "$NEWROOT"/forcefsck ] && rm -f "$NEWROOT"/forcefsck 2>/dev/null
     [ -f "$NEWROOT"/.autofsck ] && rm -f "$NEWROOT"/.autofsck 2>/dev/null
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rootfs-block: avoid remount when options don't change
       [not found] ` <20120411220043.883609D401E-k/4jFdqg8LLlyo9zxV8I99HuzzzSOjJt@public.gmane.org>
@ 2012-04-19 10:14   ` Harald Hoyer
  0 siblings, 0 replies; 2+ messages in thread
From: Harald Hoyer @ 2012-04-19 10:14 UTC (permalink / raw)
  To: Daniel Drake; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA

Am 12.04.2012 00:00, schrieb Daniel Drake:
> Mounting, unmounting and then mounting a disk partition takes some
> time.
> 
> On embedded systems such as OLPC XO where we disable fsck and fstab
> reading, the root options are not going to change throughout the
> mount_root() function, so remounting is time consuming and without
> change.
> 
> Detect and optimize for this case so that the filesystem is only
> mounted once.
> ---
>  modules.d/95rootfs-block/mount-root.sh |   12 ++++++++----
>  1 files changed, 8 insertions(+), 4 deletions(-)
> 

pushed

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-19 10:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-11 22:00 [PATCH] rootfs-block: avoid remount when options don't change Daniel Drake
     [not found] ` <20120411220043.883609D401E-k/4jFdqg8LLlyo9zxV8I99HuzzzSOjJt@public.gmane.org>
2012-04-19 10:14   ` Harald Hoyer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.