[RFC,4/4] xfs: enforce a maximum total iclog buffer size
diff mbox

Message ID 20171023144646.50107-5-bfoster@redhat.com
State New
Headers show

Commit Message

Brian Foster Oct. 23, 2017, 2:46 p.m. UTC
Since mkfs has historically had an issue creating a very small
filesystems with a log smaller than the minimum log size, add an
extra layer of runtime protection around the log buffer count and
size parameters. Restrict the total log buffer size to 1/2 of the
physical log size, otherwise fail the mount.

The default log buffer count and size is 8 and 32k, respectively.
This total size of 256k results in a minimum log size requirement of
512k, which is well outside even the smallest logs created by broken
formats. Therefore, this change should only affect users who
explicitly attempt to use larger log buffer counts/sizes with such
filesystems.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_log.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Patch
diff mbox

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index e282fd8..5966cab 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1453,6 +1453,14 @@  xlog_alloc_log(
 
 	xlog_get_iclog_buffer_size(mp, log);
 
+	error = -EINVAL;
+	if (log->l_iclog_bufs * log->l_iclog_size > (log->l_logsize >> 1)) {
+		xfs_warn(mp,
+	"total iclog buffer size (logbufs * logbsize) cannot exceed %d bytes",
+			 (log->l_logsize >> 1));
+		goto out_free_log;
+	}
+
 	/*
 	 * Use a NULL block for the extra log buffer used during splits so that
 	 * it will trigger errors if we ever try to do IO on it without first