{"id":2221649,"url":"http://patchwork.ozlabs.org/api/patches/2221649/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260410035635.1381920-1-guzebing1612@gmail.com/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260410035635.1381920-1-guzebing1612@gmail.com>","list_archive_url":null,"date":"2026-04-10T03:56:35","name":"ext4: make mballoc max prealloc size configurable","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"23cddd5bd325af949231baeae40298788c4d606f","submitter":{"id":93111,"url":"http://patchwork.ozlabs.org/api/people/93111/?format=json","name":"guzebing","email":"guzebing1612@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260410035635.1381920-1-guzebing1612@gmail.com/mbox/","series":[{"id":499385,"url":"http://patchwork.ozlabs.org/api/series/499385/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=499385","date":"2026-04-10T03:56:35","name":"ext4: make mballoc max prealloc size configurable","version":1,"mbox":"http://patchwork.ozlabs.org/series/499385/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221649/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221649/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <SRS0=wEJw=CJ=vger.kernel.org=linux-ext4+bounces-15732-patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ext4@vger.kernel.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","patchwork-incoming@ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=Vxu0JNNn;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org;\n envelope-from=srs0=wejw=cj=vger.kernel.org=linux-ext4+bounces-15732-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=172.105.105.114 arc.chain=subspace.kernel.org","gandalf.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","gandalf.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=Vxu0JNNn;\n\tdkim-atps=neutral","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15732-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"Vxu0JNNn\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.214.182","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com"],"Received":["from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fsNKc4y1Tz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 13:57:07 +1000 (AEST)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4fsNKb5w6jz4wJ7\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 13:57:07 +1000 (AEST)","by gandalf.ozlabs.org (Postfix)\n\tid 4fsNKb5frsz4wLx; Fri, 10 Apr 2026 13:57:07 +1000 (AEST)","from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby gandalf.ozlabs.org (Postfix) with ESMTPS id 4fsNKV3Jswz4wJ7\n\tfor <patchwork-incoming@ozlabs.org>; Fri, 10 Apr 2026 13:57:02 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 23F7C3025F59\n\tfor <patchwork-incoming@ozlabs.org>; Fri, 10 Apr 2026 03:56:51 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 1D6B1330675;\n\tFri, 10 Apr 2026 03:56:47 +0000 (UTC)","from mail-pl1-f182.google.com (mail-pl1-f182.google.com\n [209.85.214.182])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 904CD32D7F8\n\tfor <linux-ext4@vger.kernel.org>; Fri, 10 Apr 2026 03:56:45 +0000 (UTC)","by mail-pl1-f182.google.com with SMTP id\n d9443c01a7336-2b23fcf90b2so15523085ad.3\n        for <linux-ext4@vger.kernel.org>;\n Thu, 09 Apr 2026 20:56:45 -0700 (PDT)","from n232-167-136.byted.org ([36.110.163.104])\n        by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-2b2d4f37086sm10850555ad.68.2026.04.09.20.56.41\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Thu, 09 Apr 2026 20:56:44 -0700 (PDT)"],"ARC-Seal":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1775793427; cv=pass;\n\tb=KM91Lo3gmks5sjw/HCg7Eu+g4/yBWATWb+SFbyJZ7jcOJmPkaBtjcKroh128Qus4OeoSL5tdMYy4wet2zR2YXA3QL1R4do02t0K4Bfl229Bx/SXJqx/hNjZSpxVykVJqKBo7+zgfU4ZkvYY5ZSY1nm+H+ocPf38qUNw40gVXdxkMURadd9Lf0KTECLzzZCxTJqZ6lZgkFXhfG3ReF4DGaS3LmhVILjwZcWQFXz9UvlQTtYfcZazutjoAohQC5HSFrwRwQPjym53Aaz3tLifrxPIEh9ey2K1ZFUmOp12hiG6IKsuIOtOsagTkaGny1dgKLg8tCXAvM2Kagx4rXpGf3g==","i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775793406; cv=none;\n b=dXk7p/vzzu6gTI0Ek1b4F//sSBWlYPz+mpF8Iyyuepi14tiD2UzkpsUNsV8eLxCkdX7nwmZfkI0vfKk9LxAr2jCKGtu6focGpxj8zR1byUe0NEdm8vMR2Av+pb9vm+8EzV/1ZZImNcD7rZehHxlKPCYCkl0g5s7CBghg1VjVxCo="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1775793427; c=relaxed/relaxed;\n\tbh=68Y2KOu6IjWpqsJxmRaUt28cJkLdrMRf5M9uj6SY5BA=;\n\th=From:To:Cc:Subject:Date:Message-Id:MIME-Version;\n b=v6K88INpImkK86eNOCIKdug6V7zZHhInsi6NYqnJ3ts+otBzTUrC+6fCfbntid4jhhT4pJqTqsjxbhMAAyiPx9AScBiHF2Z1POfITTZC/0/uoSWXtrWUjBHSn084W7+2zrGbeK0GDj+fRvFxGuWsZYWJj3SE4lltdhiAPYysRSqGjCKGZIQGbKUdLh/TqCnc7sf6CbT4Ido0UOm6SEv8lw8nI58w0ogjQqWwJY8nZZolbRJ+mroistIrk4Tnrx5AxlFUM+ofBJXYfWPdKbootuzEIFqZDOwq92CCSDXxfhJXaZ+tl/WujFBR+58XY87FV1aurOWrNUHyF/DhPi/vqg==","i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775793406; c=relaxed/simple;\n\tbh=6VgrxJ/EKckn/f1V4UYs/as2VQQE71/j43gR36E7BhE=;\n\th=From:To:Cc:Subject:Date:Message-Id:MIME-Version;\n b=DIZ90CI+qiKoO/BK6wuJPRSr5v2sCtCKf46KMSB4BhUHRVSW9T9vny5cajEgNN2N5OSrpl41N3tUJVXlTE14y5TICHM3sHf5S8NHuCfL1t7akVUIsFF2pmOraL/uwib5O6iWntUCjsY1w5w7ofEnKu8rOCKq0vY3Y60FZkl5p04="],"ARC-Authentication-Results":["i=2; gandalf.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com; dkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=Vxu0JNNn; dkim-atps=neutral;\n spf=pass (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15732-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=Vxu0JNNn; arc=none smtp.client-ip=209.85.214.182"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1775793405; x=1776398205;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:from:to:cc:subject:date:message-id:reply-to;\n        bh=68Y2KOu6IjWpqsJxmRaUt28cJkLdrMRf5M9uj6SY5BA=;\n        b=Vxu0JNNnwdFztIyl/KOQvCeKter0rO6CAn6x/W0jP5s0Cs/JwNFU9YbANt/WJoizG6\n         qt/ljOHzC5cSgEof2vDaSKxO4wxhpt/ES3EH0C4IWPGeZzqX6ebkJTsMxiVj+dek+9zB\n         OcryjeCewqh5rnatv2n6EjCZt5NhZu2oHna1rMctS15fklvRc+LbdVUlSwBgwYOWF6Yo\n         BoO7t99bl2xh5+6vfeukcc/cRVauyDI9w6LJuU7qalJtjNybTY1fgDiKsfZSpQPUeZN8\n         iHnx+Dr4lGl1p08FzUEaCeGHTziPaXIhzYUgbWlFBT5VjOR5GPmrUlUs41T8EuTZyuWS\n         ZfZQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1775793405; x=1776398205;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=68Y2KOu6IjWpqsJxmRaUt28cJkLdrMRf5M9uj6SY5BA=;\n        b=hcnGpfv0q2r0RIQvedien9ewg4LUipUzJvv0gDo9fYqpzSOygFlcgLbdJ9TBZD8yMP\n         lRhHRMVLo1H2e5BfvyFHd4lQJtsfvfKtmHRte4Tyfz64oaWl9DNbrGKCGFfKUmFuooBT\n         5eHDs+ZJ5KG2T6h3WiUeOJ868wwTKlTkhF8kTWMUggSDDghckV7atT0N4YT+82d2lGOY\n         h6+P5WAQqHYo9BNf9JQa+qX/nkpFEAWYdAox/0481M8k4llosjCiXbL8KDXjiWBQ8Xpi\n         aRPDCRmz4dD5LEXGW+HJuqsI3hSZuEex8M7o1pRPQs5241fUjALOUB/vnQm9T3Kp0VwD\n         anRg==","X-Forwarded-Encrypted":"i=1;\n AJvYcCUGWIXwsD/AIH7e7sbs9FipL66CMDd35v6zRa1vOZn0A+m5T9vtU9Mi5P8Yddz5lW5+n8XbNQADnMlF@vger.kernel.org","X-Gm-Message-State":"AOJu0Yxikr37602bkxrA/oxg5kWXrqWKXcNi3S0tiLg9qzI4qvdvymn+\n\t1vjC3v2UQiCrpAjQ+4q/jqPyEQ5MDri8bs9dYAoeHM1fx/yuMiwqsd8G","X-Gm-Gg":"AeBDieskdtJ4IA9MJqB36SYf+dg4PSu7h1o/UlRcnL8TGWwefjqWYk3J2KJmBnVFMrM\n\tEp2UCrJf+Wg+QodWTxgLkNsD16BxwGhF4FBtsI3t9eqMf4gBbeDnphoEqUJtJTEfj/0XQZGx+lV\n\tuactrulDUjkzuSWVGc6R98NYEfnj6xysH8nJFQoQs21BfIsTDdy1pe6ejh/AGjoxoQnBKCypkNf\n\t0pfs4UW1dgVZYfzTb3yGGMc+Gn8xrFB+uiPxkDpAgfw7uYT1bKwoM4xS0XG4Pfc9M2RBhlVoTo6\n\tGyuCyVmxR+Z4JKvgn8PZyxZt2Rx/cGy3q6wwOcOK6h/qQ3KUfkvlyNLIzi+1nhZNzPgBA7Cco7c\n\tJGX74GNPKS8NDcwYxWh2DOMgParVZkfqTzlzWDN4rT17clB2Fu28f1uXwgGd1C1150zBqYEQTnj\n\tIsQbJNiBenfkZp35PMLXnNNef6EgMxbD/aGxrFyvJCh98l0b3rovta","X-Received":"by 2002:a17:902:b48f:b0:2b2:d12e:beae with SMTP id\n d9443c01a7336-2b2d5a65c0bmr10742495ad.42.1775793404825;\n        Thu, 09 Apr 2026 20:56:44 -0700 (PDT)","From":"guzebing <guzebing1612@gmail.com>","To":"tytso@mit.edu,\n\tadilger.kernel@dilger.ca,\n\tlibaokun@linux.alibaba.com,\n\tjack@suse.cz,\n\tojaswin@linux.ibm.com,\n\tritesh.list@gmail.com,\n\tyi.zhang@huawei.com,\n\tguzebing@bytedance.com","Cc":"linux-kernel@vger.kernel.org,\n\tlinux-ext4@vger.kernel.org","Subject":"[PATCH] ext4: make mballoc max prealloc size configurable","Date":"Fri, 10 Apr 2026 11:56:35 +0800","Message-Id":"<20260410035635.1381920-1-guzebing1612@gmail.com>","X-Mailer":"git-send-email 2.20.1","Precedence":"bulk","X-Mailing-List":"linux-ext4@vger.kernel.org","List-Id":"<linux-ext4.vger.kernel.org>","List-Subscribe":"<mailto:linux-ext4+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ext4+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Spam-Status":"No, score=-1.2 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,\n\tFREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,\n\tMAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled\n\tversion=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"From: Guzebing <guzebing@bytedance.com>\n\nAdd per-superblock sysfs knob mb_max_prealloc_kb (min 8MiB, roundup\npow2) and use it in request normalization.\n\nWhen multiple tasks write to different files on the same filesystem\nconcurrently, each file ends up with 8 MiB extents. If the preallocation\nsize is increased, the resulting extent size grows accordingly. Due\nto the readahead mechanism on NVMe SSDs, files with larger extents\nachieve higher sequential read throughput.\n\nOn an ext4 filesystem on an NVMe Gen4 data drive, dd read throughput\nfor a file with 8 MiB extents is 455 MB/s, while for a file with\n32 MiB extents it reaches 702 MB/s.\n\nSteps to reproduce:\n1.Configure the maximum preallocation size to 8 MiB or 32 MiB:\necho 8192 > /sys/fs/ext4/nvme13n1/mb_max_prealloc_kb\necho 32768 > /sys/fs/ext4/nvme13n1/mb_max_prealloc_kb\n\n2.Run the following commands simultaneously so that the extents of\nthe two files are physically interleaved, resulting in 8 MiB or 32 MiB\nextents:\ndd if=/dev/zero of=/mnt/store1/501.txt bs=128K count=80K oflag=direct\ndd if=/dev/zero of=/mnt/store1/502.txt bs=128K count=80K oflag=direct\n\n3.Read back the file and measure the read throughput:\ndd if=/mnt/store1/501.txt of=/dev/null bs=128K count=80K iflag=direct\n\nSigned-off-by: Guzebing <guzebing@bytedance.com>\n---\n Documentation/ABI/testing/sysfs-fs-ext4 |  8 +++++++\n fs/ext4/ext4.h                          |  1 +\n fs/ext4/mballoc.c                       |  2 +-\n fs/ext4/super.c                         |  1 +\n fs/ext4/sysfs.c                         | 28 ++++++++++++++++++++++++-\n 5 files changed, 38 insertions(+), 2 deletions(-)","diff":"diff --git a/Documentation/ABI/testing/sysfs-fs-ext4 b/Documentation/ABI/testing/sysfs-fs-ext4\nindex 2edd0a6672d3a..316ae1d1ec18b 100644\n--- a/Documentation/ABI/testing/sysfs-fs-ext4\n+++ b/Documentation/ABI/testing/sysfs-fs-ext4\n@@ -48,6 +48,14 @@ Description:\n \t\twill have its blocks allocated out of its own unique\n \t\tpreallocation pool.\n \n+What:\t\t/sys/fs/ext4/<disk>/mb_max_prealloc_kb\n+Date:\t\tApril 2026\n+Contact:\t\"Linux Ext4 Development List\" <linux-ext4@vger.kernel.org>\n+Description:\n+\t\tMaximum size (in kilobytes) used by the multiblock allocator's\n+\t\tnormalized request preallocation heuristic. Values are rounded\n+\t\tup to a power of two and clamped to a minimum of 8192 (8MiB).\n+\n What:\t\t/sys/fs/ext4/<disk>/inode_readahead_blks\n Date:\t\tMarch 2008\n Contact:\t\"Theodore Ts'o\" <tytso@mit.edu>\ndiff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h\nindex 7617e2d454ea5..bce99740740f5 100644\n--- a/fs/ext4/ext4.h\n+++ b/fs/ext4/ext4.h\n@@ -1634,6 +1634,7 @@ struct ext4_sb_info {\n \tunsigned int s_mb_best_avail_max_trim_order;\n \tunsigned int s_sb_update_sec;\n \tunsigned int s_sb_update_kb;\n+\tunsigned int s_mb_max_prealloc_kb;\n \n \t/* where last allocation was done - for stream allocation */\n \text4_group_t *s_mb_last_groups;\ndiff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c\nindex bb58eafb87bcd..f5f63c56fcdac 100644\n--- a/fs/ext4/mballoc.c\n+++ b/fs/ext4/mballoc.c\n@@ -4589,7 +4589,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,\n \t\t\t\t\t(8<<20)>>bsbits, max, 8 * 1024)) {\n \t\tstart_off = ((loff_t)ac->ac_o_ex.fe_logical >>\n \t\t\t\t\t\t\t(23 - bsbits)) << 23;\n-\t\tsize = 8 * 1024 * 1024;\n+\t\tsize = (loff_t)sbi->s_mb_max_prealloc_kb << 10;\n \t} else {\n \t\tstart_off = (loff_t) ac->ac_o_ex.fe_logical << bsbits;\n \t\tsize\t  = (loff_t) EXT4_C2B(sbi,\ndiff --git a/fs/ext4/super.c b/fs/ext4/super.c\nindex a34efb44e73d7..f815e31657cc9 100644\n--- a/fs/ext4/super.c\n+++ b/fs/ext4/super.c\n@@ -5447,6 +5447,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)\n \t\tsbi->s_stripe = 0;\n \t}\n \tsbi->s_extent_max_zeroout_kb = 32;\n+\tsbi->s_mb_max_prealloc_kb = 8 * 1024;\n \n \t/*\n \t * set up enough so that it can read an inode\ndiff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c\nindex 923b375e017fa..6339492eb2fa7 100644\n--- a/fs/ext4/sysfs.c\n+++ b/fs/ext4/sysfs.c\n@@ -10,6 +10,8 @@\n \n #include <linux/time.h>\n #include <linux/fs.h>\n+#include <linux/log2.h>\n+#include <linux/limits.h>\n #include <linux/seq_file.h>\n #include <linux/slab.h>\n #include <linux/proc_fs.h>\n@@ -41,6 +43,7 @@ typedef enum {\n \tattr_pointer_atomic,\n \tattr_journal_task,\n \tattr_err_report_sec,\n+\tattr_mb_max_prealloc_kb,\n } attr_id_t;\n \n typedef enum {\n@@ -115,6 +118,25 @@ static ssize_t reserved_clusters_store(struct ext4_sb_info *sbi,\n \treturn count;\n }\n \n+static ssize_t mb_max_prealloc_kb_store(struct ext4_sb_info *sbi,\n+\t\t\t\t\tconst char *buf, size_t count)\n+{\n+\tunsigned int v;\n+\tint ret;\n+\tunsigned long rounded;\n+\n+\tret = kstrtouint(skip_spaces(buf), 0, &v);\n+\tif (ret)\n+\t\treturn ret;\n+\tif (v < 8192)\n+\t\tv = 8192;\n+\trounded = roundup_pow_of_two((unsigned long)v);\n+\tif (rounded > UINT_MAX)\n+\t\treturn -EINVAL;\n+\tsbi->s_mb_max_prealloc_kb = (unsigned int)rounded;\n+\treturn count;\n+}\n+\n static ssize_t trigger_test_error(struct ext4_sb_info *sbi,\n \t\t\t\t  const char *buf, size_t count)\n {\n@@ -288,6 +310,7 @@ EXT4_RW_ATTR_SBI_UI(mb_prefetch_limit, s_mb_prefetch_limit);\n EXT4_RW_ATTR_SBI_UL(last_trim_minblks, s_last_trim_minblks);\n EXT4_RW_ATTR_SBI_UI(sb_update_sec, s_sb_update_sec);\n EXT4_RW_ATTR_SBI_UI(sb_update_kb, s_sb_update_kb);\n+EXT4_ATTR_OFFSET(mb_max_prealloc_kb, 0644, mb_max_prealloc_kb, ext4_sb_info, s_mb_max_prealloc_kb);\n \n static unsigned int old_bump_val = 128;\n EXT4_ATTR_PTR(max_writeback_mb_bump, 0444, pointer_ui, &old_bump_val);\n@@ -341,6 +364,7 @@ static struct attribute *ext4_attrs[] = {\n \tATTR_LIST(last_trim_minblks),\n \tATTR_LIST(sb_update_sec),\n \tATTR_LIST(sb_update_kb),\n+\tATTR_LIST(mb_max_prealloc_kb),\n \tATTR_LIST(err_report_sec),\n \tNULL,\n };\n@@ -431,6 +455,7 @@ static ssize_t ext4_generic_attr_show(struct ext4_attr *a,\n \tcase attr_mb_order:\n \tcase attr_pointer_pi:\n \tcase attr_pointer_ui:\n+\tcase attr_mb_max_prealloc_kb:\n \t\tif (a->attr_ptr == ptr_ext4_super_block_offset)\n \t\t\treturn sysfs_emit(buf, \"%u\\n\", le32_to_cpup(ptr));\n \t\treturn sysfs_emit(buf, \"%u\\n\", *((unsigned int *) ptr));\n@@ -557,6 +582,8 @@ static ssize_t ext4_attr_store(struct kobject *kobj,\n \t\treturn reserved_clusters_store(sbi, buf, len);\n \tcase attr_inode_readahead:\n \t\treturn inode_readahead_blks_store(sbi, buf, len);\n+\tcase attr_mb_max_prealloc_kb:\n+\t\treturn mb_max_prealloc_kb_store(sbi, buf, len);\n \tcase attr_trigger_test_error:\n \t\treturn trigger_test_error(sbi, buf, len);\n \tcase attr_err_report_sec:\n@@ -695,4 +722,3 @@ void ext4_exit_sysfs(void)\n \tremove_proc_entry(proc_dirname, NULL);\n \text4_proc_root = NULL;\n }\n-\n","prefixes":[]}