Skip to content

Commit 8e9800f

Browse files
author
Darrick J. Wong
committed
xfs: don't allow log writes if the data device is readonly
While running generic/050 with an external log, I observed this warning in dmesg: Trying to write to read-only block-device sda4 (partno 4) WARNING: CPU: 2 PID: 215677 at block/blk-core.c:704 submit_bio_checks+0x256/0x510 Call Trace: submit_bio_noacct+0x2c/0x430 _xfs_buf_ioapply+0x283/0x3c0 [xfs] __xfs_buf_submit+0x6a/0x210 [xfs] xfs_buf_delwri_submit_buffers+0xf8/0x270 [xfs] xfsaild+0x2db/0xc50 [xfs] kthread+0x14b/0x170 I think this happened because we tried to cover the log after a readonly mount, and the AIL tried to write the primary superblock to the data device. The test marks the data device readonly, but it doesn't do the same to the external log device. Therefore, XFS thinks that the log is writable, even though AIL writes whine to dmesg because the data device is read only. Fix this by amending xfs_log_writable to prevent writes when the AIL can't possible write anything into the filesystem. Note: As for the external log or the rt devices being readonly-- xfs_blkdev_get will complain about that if we aren't doing a norecovery mount. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Brian Foster <[email protected]>
1 parent d4f74e1 commit 8e9800f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fs/xfs/xfs_log.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,15 @@ xfs_log_writable(
355355
struct xfs_mount *mp)
356356
{
357357
/*
358-
* Never write to the log on norecovery mounts, if the block device is
359-
* read-only, or if the filesystem is shutdown. Read-only mounts still
360-
* allow internal writes for log recovery and unmount purposes, so don't
361-
* restrict that case here.
358+
* Do not write to the log on norecovery mounts, if the data or log
359+
* devices are read-only, or if the filesystem is shutdown. Read-only
360+
* mounts allow internal writes for log recovery and unmount purposes,
361+
* so don't restrict that case.
362362
*/
363363
if (mp->m_flags & XFS_MOUNT_NORECOVERY)
364364
return false;
365+
if (xfs_readonly_buftarg(mp->m_ddev_targp))
366+
return false;
365367
if (xfs_readonly_buftarg(mp->m_log->l_targ))
366368
return false;
367369
if (XFS_FORCED_SHUTDOWN(mp))

0 commit comments

Comments
 (0)