mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
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>
This commit is contained in:
parent
5088aad3d3
commit
bfecc4091e
1 changed files with 18 additions and 3 deletions
|
@ -380,10 +380,11 @@ xfs_blkdev_get(
|
||||||
struct file **bdev_filep)
|
struct file **bdev_filep)
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
blk_mode_t mode;
|
||||||
|
|
||||||
*bdev_filep = bdev_file_open_by_path(name,
|
mode = sb_open_mode(mp->m_super->s_flags);
|
||||||
BLK_OPEN_READ | BLK_OPEN_WRITE | BLK_OPEN_RESTRICT_WRITES,
|
*bdev_filep = bdev_file_open_by_path(name, mode,
|
||||||
mp->m_super, &fs_holder_ops);
|
mp->m_super, &fs_holder_ops);
|
||||||
if (IS_ERR(*bdev_filep)) {
|
if (IS_ERR(*bdev_filep)) {
|
||||||
error = PTR_ERR(*bdev_filep);
|
error = PTR_ERR(*bdev_filep);
|
||||||
*bdev_filep = NULL;
|
*bdev_filep = NULL;
|
||||||
|
@ -1969,6 +1970,20 @@ xfs_remount_rw(
|
||||||
struct xfs_sb *sbp = &mp->m_sb;
|
struct xfs_sb *sbp = &mp->m_sb;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp &&
|
||||||
|
bdev_read_only(mp->m_logdev_targp->bt_bdev)) {
|
||||||
|
xfs_warn(mp,
|
||||||
|
"ro->rw transition prohibited by read-only logdev");
|
||||||
|
return -EACCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mp->m_rtdev_targp &&
|
||||||
|
bdev_read_only(mp->m_rtdev_targp->bt_bdev)) {
|
||||||
|
xfs_warn(mp,
|
||||||
|
"ro->rw transition prohibited by read-only rtdev");
|
||||||
|
return -EACCES;
|
||||||
|
}
|
||||||
|
|
||||||
if (xfs_has_norecovery(mp)) {
|
if (xfs_has_norecovery(mp)) {
|
||||||
xfs_warn(mp,
|
xfs_warn(mp,
|
||||||
"ro->rw transition prohibited on norecovery mount");
|
"ro->rw transition prohibited on norecovery mount");
|
||||||
|
|
Loading…
Add table
Reference in a new issue