Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xfs: allow ro mounts if rtdev or logdev are read-only

Allow read-only mounts on rtdevs and logdevs that are marked as
read-only and make sure those mounts can't be remounted read-write.

Use the sb_open_mode helper to make sure that we don't try to open
devices with write access enabled for read-only mounts.

Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>

authored by

Hans Holmberg and committed by
Carlos Maiolino
bfecc409 5088aad3

+18 -3
+18 -3
fs/xfs/xfs_super.c
··· 380 380 struct file **bdev_filep) 381 381 { 382 382 int error = 0; 383 + blk_mode_t mode; 383 384 384 - *bdev_filep = bdev_file_open_by_path(name, 385 - BLK_OPEN_READ | BLK_OPEN_WRITE | BLK_OPEN_RESTRICT_WRITES, 386 - mp->m_super, &fs_holder_ops); 385 + mode = sb_open_mode(mp->m_super->s_flags); 386 + *bdev_filep = bdev_file_open_by_path(name, mode, 387 + mp->m_super, &fs_holder_ops); 387 388 if (IS_ERR(*bdev_filep)) { 388 389 error = PTR_ERR(*bdev_filep); 389 390 *bdev_filep = NULL; ··· 1969 1968 { 1970 1969 struct xfs_sb *sbp = &mp->m_sb; 1971 1970 int error; 1971 + 1972 + if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp && 1973 + bdev_read_only(mp->m_logdev_targp->bt_bdev)) { 1974 + xfs_warn(mp, 1975 + "ro->rw transition prohibited by read-only logdev"); 1976 + return -EACCES; 1977 + } 1978 + 1979 + if (mp->m_rtdev_targp && 1980 + bdev_read_only(mp->m_rtdev_targp->bt_bdev)) { 1981 + xfs_warn(mp, 1982 + "ro->rw transition prohibited by read-only rtdev"); 1983 + return -EACCES; 1984 + } 1972 1985 1973 1986 if (xfs_has_norecovery(mp)) { 1974 1987 xfs_warn(mp,