All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libmultipath: open_file: rewind after writing the header
@ 2026-11-06 15:24 Alex Brett
  2026-11-06 20:06 ` Benjamin Marzinski
  2026-11-06 21:14 ` Martin Wilck
  0 siblings, 2 replies; 3+ messages in thread
From: Alex Brett @ 2026-11-06 15:24 UTC (permalink / raw)
  To: dm-devel; +Cc: Martin Wilck, Benjamin Marzinski, Alex Brett

When creating a new file, open_file() returns it with the offset after
the header it has just written, but on opening an existing file it will
return it with the offset at 0.

_read_bindings_file() reads sequentially from the returned fd, so on a
newly created bindings file the header check in _check_bindings_file()
hits EOF and declares the file bad. Without -B this is masked by
rewriting the file, but "multipath -B" may not write it and aborts:

  ERROR: bad settings in read-only bindings file /etc/multipath/bindings
  fatal configuration error, aborting

This affects the first "multipath -B" on any system without a bindings
file, such as an installer environment.

The wwids and prkeys code paths seek before every access and are
unaffected.

Fixes: 7eaeb33ae9f7 ("multipathd: watch bindings file with inotify + timestamp")
Signed-off-by: Alex Brett <alex.brett@citrix.com>
Assisted-by: Claude:claude-opus-5-5
---
 libmultipath/file.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libmultipath/file.c b/libmultipath/file.c
index ce9ff610..215a48cd 100644
--- a/libmultipath/file.c
+++ b/libmultipath/file.c
@@ -159,6 +159,11 @@ open_file(const char *file, int *can_write, const char *header)
 			goto fail;
 		}
 		fsync(fd);
+		if (lseek(fd, 0, SEEK_SET) < 0) {
+			condlog(0, "Cannot rewind file %s : %s", file,
+				strerror(errno));
+			goto fail;
+		}
 		condlog(3, "Initialized new file [%s]", file);
 	}
 
-- 
2.53.0


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

* Re: [PATCH] libmultipath: open_file: rewind after writing the header
  2026-11-06 15:24 [PATCH] libmultipath: open_file: rewind after writing the header Alex Brett
@ 2026-11-06 20:06 ` Benjamin Marzinski
  2026-11-06 21:14 ` Martin Wilck
  1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Marzinski @ 2026-11-06 20:06 UTC (permalink / raw)
  To: Alex Brett; +Cc: dm-devel, Martin Wilck

On Fri, Nov 06, 2026 at 03:24:44PM +0000, Alex Brett wrote:
> When creating a new file, open_file() returns it with the offset after
> the header it has just written, but on opening an existing file it will
> return it with the offset at 0.
> 
> _read_bindings_file() reads sequentially from the returned fd, so on a
> newly created bindings file the header check in _check_bindings_file()
> hits EOF and declares the file bad. Without -B this is masked by
> rewriting the file, but "multipath -B" may not write it and aborts:
> 
>   ERROR: bad settings in read-only bindings file /etc/multipath/bindings
>   fatal configuration error, aborting
> 
> This affects the first "multipath -B" on any system without a bindings
> file, such as an installer environment.
> 
> The wwids and prkeys code paths seek before every access and are
> unaffected.
> 
> Fixes: 7eaeb33ae9f7 ("multipathd: watch bindings file with inotify + timestamp")
> Signed-off-by: Alex Brett <alex.brett@citrix.com>
> Assisted-by: Claude:claude-opus-5-5

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>


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

* Re: [PATCH] libmultipath: open_file: rewind after writing the header
  2026-11-06 15:24 [PATCH] libmultipath: open_file: rewind after writing the header Alex Brett
  2026-11-06 20:06 ` Benjamin Marzinski
@ 2026-11-06 21:14 ` Martin Wilck
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Wilck @ 2026-11-06 21:14 UTC (permalink / raw)
  To: dm-devel, Alex Brett; +Cc: Benjamin Marzinski


On Fri, 06 Nov 2026 15:24:44 +0000, Alex Brett wrote:
> libmultipath: open_file: rewind after writing the header

Applied, thanks!

[1/1] libmultipath: open_file: rewind after writing the header
      commit: 29c489fe288f461789970ff7f607a7ded16d1c59

Best regards,
-- 
Martin Wilck <mwilck@suse.com>


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

end of thread, other threads:[~2026-11-06 21:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06 15:24 [PATCH] libmultipath: open_file: rewind after writing the header Alex Brett
2026-11-06 20:06 ` Benjamin Marzinski
2026-11-06 21:14 ` Martin Wilck

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.