* Is labelling a mounted ext2/3/4 file system safe and supported? @ 2021-07-26 18:45 Mike Fleetwood 2021-07-26 20:50 ` Reindl Harald 0 siblings, 1 reply; 5+ messages in thread From: Mike Fleetwood @ 2021-07-26 18:45 UTC (permalink / raw) To: linux-ext4 Hi, Using e2label to set a new label for a mounted ext4 seems to work, but is it a safe and supported thing to do? Google search doesn't seem to know. Thanks, Mike ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Is labelling a mounted ext2/3/4 file system safe and supported? 2021-07-26 18:45 Is labelling a mounted ext2/3/4 file system safe and supported? Mike Fleetwood @ 2021-07-26 20:50 ` Reindl Harald 2021-07-27 7:32 ` Mike Fleetwood 0 siblings, 1 reply; 5+ messages in thread From: Reindl Harald @ 2021-07-26 20:50 UTC (permalink / raw) To: Mike Fleetwood, linux-ext4 Am 26.07.21 um 20:45 schrieb Mike Fleetwood: > Hi, > > Using e2label to set a new label for a mounted ext4 seems to work, but > is it a safe and supported thing to do? it is ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Is labelling a mounted ext2/3/4 file system safe and supported? 2021-07-26 20:50 ` Reindl Harald @ 2021-07-27 7:32 ` Mike Fleetwood 2021-07-27 7:49 ` Andreas Dilger 0 siblings, 1 reply; 5+ messages in thread From: Mike Fleetwood @ 2021-07-27 7:32 UTC (permalink / raw) To: Reindl Harald; +Cc: linux-ext4 On Mon, 26 Jul 2021 at 21:50, Reindl Harald <h.reindl@thelounge.net> wrote: > Am 26.07.21 um 20:45 schrieb Mike Fleetwood: > > Hi, > > > > Using e2label to set a new label for a mounted ext4 seems to work, but > > is it a safe and supported thing to do? > > it is Is there some documentation which states it's safe to write to the label while mounted? I ask because 1) I am looking at adding such support into GParted and 2) I don't understand how it can be safe. Looking at the e2label source code, it just reads the superblock, updates the label and writes the super block. How is that safe and persistent when presumably the linux kernel has an in-memory copy of the superblock will be written at unmount and presumable sync. Thanks, Mike ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Is labelling a mounted ext2/3/4 file system safe and supported? 2021-07-27 7:32 ` Mike Fleetwood @ 2021-07-27 7:49 ` Andreas Dilger 2021-07-27 22:06 ` Theodore Ts'o 0 siblings, 1 reply; 5+ messages in thread From: Andreas Dilger @ 2021-07-27 7:49 UTC (permalink / raw) To: Mike Fleetwood; +Cc: Reindl Harald, linux-ext4, Darrick J. Wong On Jul 27, 2021, at 01:33, Mike Fleetwood <mike.fleetwood@googlemail.com> wrote: > > On Mon, 26 Jul 2021 at 21:50, Reindl Harald <h.reindl@thelounge.net> wrote: >>> Am 26.07.21 um 20:45 schrieb Mike Fleetwood: >>> Hi, >>> >>> Using e2label to set a new label for a mounted ext4 seems to work, but >>> is it a safe and supported thing to do? >> >> it is > > Is there some documentation which states it's safe to write to the label > while mounted? > > I ask because 1) I am looking at adding such support into GParted and > 2) I don't understand how it can be safe. > > Looking at the e2label source code, it just reads the superblock, > updates the label and writes the super block. How is that safe and > persistent when presumably the linux kernel has an in-memory copy of the > superblock will be written at unmount and presumable sync. Currently, the in-memory superblock references the device buffer cache, which is the same cache that is accessed when reading the block device from userspace, so they are always consistent. There has been some discussion about adding ioctl() calls to update the filesystem label, UUID, and other fields from userspace in a safer way, but nothing has been implemented in that direction yet (possibly Darrick had some RFC patches, but they are not landed yet). Cheers, Andreas ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Is labelling a mounted ext2/3/4 file system safe and supported? 2021-07-27 7:49 ` Andreas Dilger @ 2021-07-27 22:06 ` Theodore Ts'o 0 siblings, 0 replies; 5+ messages in thread From: Theodore Ts'o @ 2021-07-27 22:06 UTC (permalink / raw) To: Andreas Dilger; +Cc: Mike Fleetwood, Reindl Harald, linux-ext4, Darrick J. Wong On Tue, Jul 27, 2021 at 01:49:39AM -0600, Andreas Dilger wrote: > > Looking at the e2label source code, it just reads the superblock, > > updates the label and writes the super block. How is that safe and > > persistent when presumably the linux kernel has an in-memory copy of the > > superblock will be written at unmount and presumable sync. > > Currently, the in-memory superblock references the device buffer cache, > which is the same cache that is accessed when reading the block > device from userspace, so they are always consistent. > > There has been some discussion about adding ioctl() calls to update > the filesystem label, UUID, and other fields from userspace in a safer way, > but nothing has been implemented in that direction yet (possibly Darrick > had some RFC patches, but they are not landed yet). As Andreas has stated, e2fsprogs programs such as e2label and tune2fs use buffered I/O to read and write the superblock, which accesses the buffer cache, which is where the kernel's copy superblock used by the file system code is located. It's not perfect; for example an updated label written by e2label might get lost when it is overwritten by a journal replay after a system crash. But for the most part, it does work. Cheers, - Ted ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-27 22:06 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-07-26 18:45 Is labelling a mounted ext2/3/4 file system safe and supported? Mike Fleetwood 2021-07-26 20:50 ` Reindl Harald 2021-07-27 7:32 ` Mike Fleetwood 2021-07-27 7:49 ` Andreas Dilger 2021-07-27 22:06 ` Theodore Ts'o
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).