mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: George Stark <gnstark@salutedevices.com>
To: <linux-kernel@vger.kernel.org>
Cc: <kernel@salutedevices.com>, George Stark <gnstark@salutedevices.com>
Subject: [PATCH 1/1] initrd: use O_SYNC flag while opening /dev/ram for write
Date: Mon, 8 Jul 2024 23:09:23 +0300	[thread overview]
Message-ID: <20240708200923.1824270-1-gnstark@salutedevices.com> (raw)

initrd image is written to the /dev/ram block device using filp_open(),
kernel_write(). After fput() /dev/ram is mounted and may fail due to not
all data is actually written to the device yet. The mount error remains
hidden due to MS_SILENT flag usage and mount_root_generic has retries.
So use O_SYNC flag to have all data written to /dev/ram before mounting.

Signed-off-by: George Stark <gnstark@salutedevices.com>
---
 init/do_mounts_rd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index ac021ae6e6fa..c9a4721c8362 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -195,7 +195,7 @@ int __init rd_load_image(char *from)
 	char rotator[4] = { '|' , '/' , '-' , '\\' };
 #endif
 
-	out_file = filp_open("/dev/ram", O_RDWR, 0);
+	out_file = filp_open("/dev/ram", O_RDWR | O_SYNC, 0);
 	if (IS_ERR(out_file))
 		goto out;
 
-- 
2.25.1


             reply	other threads:[~2024-07-08 20:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-08 20:09 George Stark [this message]
2024-07-09  6:03 ` Christoph Hellwig
2024-07-09 16:18   ` George Stark

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=20240708200923.1824270-1-gnstark@salutedevices.com \
    --to=gnstark@salutedevices.com \
    --cc=kernel@salutedevices.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®