Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2226006/?format=api
{ "id": 2226006, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2226006/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/patch/20260422021042.4157510-3-yi.zhang@huaweicloud.com/", "project": { "id": 8, "url": "http://patchwork.ozlabs.org/api/1.2/projects/8/?format=api", "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": "<20260422021042.4157510-3-yi.zhang@huaweicloud.com>", "list_archive_url": null, "date": "2026-04-22T02:10:22", "name": "[v3,02/22] ext4: factor out ext4_truncate_[up|down]()", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "592565aa5bd51bf461bee2b431b589fea9aa0ac5", "submitter": { "id": 85428, "url": "http://patchwork.ozlabs.org/api/1.2/people/85428/?format=api", "name": "Zhang Yi", "email": "yi.zhang@huaweicloud.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-ext4/patch/20260422021042.4157510-3-yi.zhang@huaweicloud.com/mbox/", "series": [ { "id": 500911, "url": "http://patchwork.ozlabs.org/api/1.2/series/500911/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/list/?series=500911", "date": "2026-04-22T02:10:23", "name": "ext4: use iomap for regular file's buffered I/O path", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/500911/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2226006/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2226006/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <SRS0=DRGs=CV=vger.kernel.org=linux-ext4+bounces-15969-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 spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=150.107.74.76; helo=mail.ozlabs.org;\n envelope-from=srs0=drgs=cv=vger.kernel.org=linux-ext4+bounces-15969-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)", "gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=172.234.253.10 arc.chain=subspace.kernel.org", "gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com", "gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15969-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=45.249.212.51", "smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com", "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=huaweicloud.com" ], "Received": [ "from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76])\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 4g0jbP6yjqz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 12:19:29 +1000 (AEST)", "from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4g0jbP6Wprz4wCM\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 12:19:29 +1000 (AEST)", "by gandalf.ozlabs.org (Postfix)\n\tid 4g0jbP6Rszz4w9Z; Wed, 22 Apr 2026 12:19:29 +1000 (AEST)", "from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4g0jbL2jCBz4wCM\n\tfor <patchwork-incoming@ozlabs.org>; Wed, 22 Apr 2026 12:19:26 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 672AB305D175\n\tfor <patchwork-incoming@ozlabs.org>; Wed, 22 Apr 2026 02:17:12 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id AD2CD328B4B;\n\tWed, 22 Apr 2026 02:17:01 +0000 (UTC)", "from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com\n [45.249.212.51])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id B772E30E84B;\n\tWed, 22 Apr 2026 02:16:58 +0000 (UTC)", "from mail.maildlp.com (unknown [172.19.163.198])\n\tby dggsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4g0jWL49m0zYQtq0;\n\tWed, 22 Apr 2026 10:15:58 +0800 (CST)", "from mail02.huawei.com (unknown [10.116.40.252])\n\tby mail.maildlp.com (Postfix) with ESMTP id C095140601;\n\tWed, 22 Apr 2026 10:16:55 +0800 (CST)", "from huaweicloud.com (unknown [10.50.85.155])\n\tby APP3 (Coremail) with SMTP id _Ch0CgB3JL6PL+hpqkgUBQ--.2635S6;\n\tWed, 22 Apr 2026 10:16:55 +0800 (CST)" ], "ARC-Seal": [ "i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1776824369; cv=pass;\n\tb=q+DZIUr1iUbTJS8KmW26/sCKQ+b6iLlUx1kULZ5crPFzsGK+VIxEinm+U1HUR7M0sUjtWriWLBBS3LLeqMgNUpbgb2g6caT5+WnTNy3OcMu61RMX3b/Dm4mwSWvto5gstEGyu5ISqUVX5PLo1oAHwvxZEB29rqd+y+sxOeKDqlHXMgWZ0Tk/cI9WRwHH0/qEQdtxvJ4rgm6MCX78duB8tf4Qw/2PhmncRzfnm1xMdmsShzAH0TMLeEcm75hCw1isoCx/PKhngZZ4Paog53tfpefYz6bJCocgImyDQZu8kDcKXkXY+eNlp/1e8nP4YmnlRTSK6shZBUJYvOTDIjaTPQ==", "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776824221; cv=none;\n b=lGWpJYUoHM0nKPJqq4R/TC/CSMnzJtaCuOqTWdL//gS81JEjS7ZsSaKxIBZ4Ad4pJjvhM4l9Wn8IhjqaTeqJe1ZWwwWToOR/ax9axa1t7uWcpQkkjFjcOYx5P67NY7J0HXhD3Vtt7z5WlXyDu2ynhqloZaXFkUi6QhFeZnIDibc=" ], "ARC-Message-Signature": [ "i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1776824369; c=relaxed/relaxed;\n\tbh=XXzxOtFPps7rI/E89TTJi8rmks692vzEIUXaWBwYoAc=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=LAYaiWFgBnXBOFnjFVfA2jcioIp4OQZEyi5cgVuc+bAy6e+Y1yxA8kIEB5JDNoHeFtyyiBePZbi9+lz6cUk+/pxrU/b6p3jhFHIii3Tz0+HOUelWasOqXRLgCqk+ecduSCcjE1mBIWe4uVHQmbMYigizJVu840NhOf12+Wh8BaPI2rwYLXDQcXoNul2HX6l2fWlpAhKdi6gAIQSvkEq5ZMCCzokKfmDnwcDf4aZgW5bNarYXGkbn9kp+EWWE3brB5aAcGEkzAb67vy26AsyYU0j2FvYdgZNNty5sBbtCKeFidWyREUI9kZOwsg2nk8ZpuujK9nD87VergsFF4ncdkA==", "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776824221; c=relaxed/simple;\n\tbh=ljs0LduNiaHg7/zUlPLWLVki8+86xSUFofFyrf+sCWw=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=MWY+sdZ1sNBxNvkHni8fdJyUOO0w6zEDI/0fwMzjpEClH5SF+qNkIU1BiQBSM+p2xpyRypyUyPvb3WW/6KYtLPapu9uNQferXHLr96ou5OKvWcEHQZJOxJOZwItmq+1o+egOvX2w2supzhWMoiaeKqDZFIxwIBb4G8V3rM2A5Gk=" ], "ARC-Authentication-Results": [ "i=2; gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com;\n spf=pass (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15969-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org", "i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com;\n spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51" ], "From": "Zhang Yi <yi.zhang@huaweicloud.com>", "To": "linux-ext4@vger.kernel.org,\n\tlinux-fsdevel@vger.kernel.org", "Cc": "linux-kernel@vger.kernel.org,\n\ttytso@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\tdjwong@kernel.org,\n\thch@infradead.org,\n\tyi.zhang@huawei.com,\n\tyi.zhang@huaweicloud.com,\n\tyizhang089@gmail.com,\n\tyangerkun@huawei.com,\n\tyukuai@fnnas.com", "Subject": "[PATCH v3 02/22] ext4: factor out ext4_truncate_[up|down]()", "Date": "Wed, 22 Apr 2026 10:10:22 +0800", "Message-ID": "<20260422021042.4157510-3-yi.zhang@huaweicloud.com>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<20260422021042.4157510-1-yi.zhang@huaweicloud.com>", "References": "<20260422021042.4157510-1-yi.zhang@huaweicloud.com>", "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-CM-TRANSID": "_Ch0CgB3JL6PL+hpqkgUBQ--.2635S6", "X-Coremail-Antispam": "1UD129KBjvJXoW3WF4UuF1xCF4xCr1DKw4fGrg_yoWxWryxpF\n\ty2ka4rCw1ruFyqgr4Iqr4UZF43ta18K3yUWFy2krZ2va4qyw1ftF1xtayFgFWUtrWUWw4j\n\tqF4DJrn5Gw48A3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2\n\t9KBjDU0xBIdaVrnRJUUUm014x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0\n\trVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2\n\tx26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0\n\tY4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw\n\tA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS\n\t0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2\n\tIY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0\n\tY48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2\n\txKxwCY1x0262kKe7AKxVWUtVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWU\n\tJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67\n\tkF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY\n\t6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0x\n\tvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVj\n\tvjDU0xZFpf9x0JUADGOUUUUU=", "X-CM-SenderInfo": "d1lo6xhdqjqx5xdzvxpfor3voofrz/", "X-Spam-Status": "No, score=-1.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDMARC_MISSING,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,\n\tSPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1", "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org" }, "content": "From: Zhang Yi <yi.zhang@huawei.com>\n\nRefactor ext4_setattr() by introducing two helper functions,\next4_truncate_up() and ext4_truncate_down(), to handle size changes. The\ncurrent ATTR_SIZE processing consolidates checks for both shrinking and\nnon-shrinking cases, leading to cluttered code. Separating the\ntruncation paths improves readability.\n\nSigned-off-by: Zhang Yi <yi.zhang@huawei.com>\n---\n fs/ext4/ext4.h | 17 ++++++\n fs/ext4/inode.c | 157 ++++++++++++++++++++++++++----------------------\n 2 files changed, 101 insertions(+), 73 deletions(-)", "diff": "diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h\nindex 94283a991e5c..9e4353432325 100644\n--- a/fs/ext4/ext4.h\n+++ b/fs/ext4/ext4.h\n@@ -3501,6 +3501,23 @@ static inline int ext4_update_inode_size(struct inode *inode, loff_t newsize)\n \treturn changed;\n }\n \n+/*\n+ * Set i_size and i_disksize to 'newsize'.\n+ *\n+ * Both i_rwsem and i_data_sem are required here to avoid races between\n+ * generic append writeback and concurrent truncate that also modify\n+ * i_size and i_disksize.\n+ */\n+static inline void ext4_set_inode_size(struct inode *inode, loff_t newsize)\n+{\n+\tWARN_ON_ONCE(S_ISREG(inode->i_mode) && !inode_is_locked(inode));\n+\n+\tdown_write(&EXT4_I(inode)->i_data_sem);\n+\ti_size_write(inode, newsize);\n+\tEXT4_I(inode)->i_disksize = newsize;\n+\tup_write(&EXT4_I(inode)->i_data_sem);\n+}\n+\n int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset,\n \t\t\t\t loff_t len);\n \ndiff --git a/fs/ext4/inode.c b/fs/ext4/inode.c\nindex 0751dc55e94f..5e913aca6499 100644\n--- a/fs/ext4/inode.c\n+++ b/fs/ext4/inode.c\n@@ -5855,6 +5855,83 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)\n \t}\n }\n \n+static int ext4_truncate_up(struct inode *inode, loff_t oldsize, loff_t newsize)\n+{\n+\text4_lblk_t old_lblk, new_lblk;\n+\thandle_t *handle;\n+\tint ret;\n+\n+\tif (!IS_ALIGNED(oldsize | newsize, i_blocksize(inode))) {\n+\t\tret = ext4_inode_attach_jinode(inode);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n+\tinode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));\n+\tif (oldsize & (i_blocksize(inode) - 1)) {\n+\t\tret = ext4_block_zero_eof(inode, oldsize, LLONG_MAX);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n+\thandle = ext4_journal_start(inode, EXT4_HT_INODE, 3);\n+\tif (IS_ERR(handle))\n+\t\treturn PTR_ERR(handle);\n+\n+\told_lblk = oldsize > 0 ? (oldsize - 1) >> inode->i_blkbits : 0;\n+\tnew_lblk = newsize > 0 ? (newsize - 1) >> inode->i_blkbits : 0;\n+\text4_fc_track_range(handle, inode, old_lblk, new_lblk);\n+\n+\text4_set_inode_size(inode, newsize);\n+\n+\tret = ext4_mark_inode_dirty(handle, inode);\n+\text4_journal_stop(handle);\n+\tif (ret)\n+\t\treturn ret;\n+\t/*\n+\t * isize extend must be called outside an active handle due to\n+\t * the lock ordering of transaction start and folio lock in the\n+\t * iomap buffered I/O path (folio lock -> transaction start).\n+\t */\n+\tpagecache_isize_extended(inode, oldsize, newsize);\n+\treturn 0;\n+}\n+\n+static int ext4_truncate_down(struct inode *inode, loff_t oldsize,\n+\t\t\t loff_t newsize, int *orphan)\n+{\n+\text4_lblk_t start_lblk;\n+\thandle_t *handle;\n+\tint ret;\n+\n+\thandle = ext4_journal_start(inode, EXT4_HT_INODE, 3);\n+\tif (IS_ERR(handle))\n+\t\treturn PTR_ERR(handle);\n+\n+\tif (ext4_handle_valid(handle)) {\n+\t\tret = ext4_orphan_add(handle, inode);\n+\t\t*orphan = 1;\n+\t\tif (ret) {\n+\t\t\text4_journal_stop(handle);\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n+\tstart_lblk = newsize > 0 ? (newsize - 1) >> inode->i_blkbits : 0;\n+\text4_fc_track_range(handle, inode, start_lblk, EXT_MAX_BLOCKS - 1);\n+\n+\text4_set_inode_size(inode, newsize);\n+\n+\tret = ext4_mark_inode_dirty(handle, inode);\n+\text4_journal_stop(handle);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (ext4_should_journal_data(inode))\n+\t\text4_wait_for_tail_page_commit(inode);\n+\treturn 0;\n+}\n+\n /*\n * ext4_setattr()\n *\n@@ -5951,7 +6028,6 @@ int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry,\n \t}\n \n \tif (attr->ia_valid & ATTR_SIZE) {\n-\t\thandle_t *handle;\n \t\tloff_t oldsize = inode->i_size;\n \t\tint shrink = (attr->ia_size < inode->i_size);\n \n@@ -6003,78 +6079,13 @@ int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry,\n \t\t\tgoto err_out;\n \t\t}\n \n-\t\tif (attr->ia_size != inode->i_size) {\n-\t\t\t/* attach jbd2 jinode for EOF folio tail zeroing */\n-\t\t\tif (attr->ia_size & (inode->i_sb->s_blocksize - 1) ||\n-\t\t\t oldsize & (inode->i_sb->s_blocksize - 1)) {\n-\t\t\t\terror = ext4_inode_attach_jinode(inode);\n-\t\t\t\tif (error)\n-\t\t\t\t\tgoto out_mmap_sem;\n-\t\t\t}\n-\n-\t\t\t/*\n-\t\t\t * Update c/mtime and tail zero the EOF folio on\n-\t\t\t * truncate up. ext4_truncate() handles the shrink case\n-\t\t\t * below.\n-\t\t\t */\n-\t\t\tif (!shrink) {\n-\t\t\t\tinode_set_mtime_to_ts(inode,\n-\t\t\t\t\t\t inode_set_ctime_current(inode));\n-\t\t\t\tif (oldsize & (inode->i_sb->s_blocksize - 1)) {\n-\t\t\t\t\terror = ext4_block_zero_eof(inode,\n-\t\t\t\t\t\t\toldsize, LLONG_MAX);\n-\t\t\t\t\tif (error)\n-\t\t\t\t\t\tgoto out_mmap_sem;\n-\t\t\t\t}\n-\t\t\t}\n-\n-\t\t\thandle = ext4_journal_start(inode, EXT4_HT_INODE, 3);\n-\t\t\tif (IS_ERR(handle)) {\n-\t\t\t\terror = PTR_ERR(handle);\n-\t\t\t\tgoto out_mmap_sem;\n-\t\t\t}\n-\t\t\tif (ext4_handle_valid(handle) && shrink) {\n-\t\t\t\terror = ext4_orphan_add(handle, inode);\n-\t\t\t\torphan = 1;\n-\t\t\t\tif (error)\n-\t\t\t\t\tgoto out_handle;\n-\t\t\t}\n-\n-\t\t\tif (shrink)\n-\t\t\t\text4_fc_track_range(handle, inode,\n-\t\t\t\t\t(attr->ia_size > 0 ? attr->ia_size - 1 : 0) >>\n-\t\t\t\t\tinode->i_sb->s_blocksize_bits,\n-\t\t\t\t\tEXT_MAX_BLOCKS - 1);\n-\t\t\telse\n-\t\t\t\text4_fc_track_range(\n-\t\t\t\t\thandle, inode,\n-\t\t\t\t\t(oldsize > 0 ? oldsize - 1 : oldsize) >>\n-\t\t\t\t\tinode->i_sb->s_blocksize_bits,\n-\t\t\t\t\t(attr->ia_size > 0 ? attr->ia_size - 1 : 0) >>\n-\t\t\t\t\tinode->i_sb->s_blocksize_bits);\n-\n-\t\t\t/*\n-\t\t\t * We have to update i_size under i_data_sem together\n-\t\t\t * with i_disksize to avoid races with writeback code\n-\t\t\t * updating disksize in mpage_map_and_submit_extent().\n-\t\t\t */\n-\t\t\tdown_write(&EXT4_I(inode)->i_data_sem);\n-\t\t\ti_size_write(inode, attr->ia_size);\n-\t\t\tEXT4_I(inode)->i_disksize = attr->ia_size;\n-\t\t\tup_write(&EXT4_I(inode)->i_data_sem);\n-\n-\t\t\terror = ext4_mark_inode_dirty(handle, inode);\n-out_handle:\n-\t\t\text4_journal_stop(handle);\n-\t\t\tif (error)\n-\t\t\t\tgoto out_mmap_sem;\n-\t\t\tif (!shrink) {\n-\t\t\t\tpagecache_isize_extended(inode, oldsize,\n-\t\t\t\t\t\t\t inode->i_size);\n-\t\t\t} else if (ext4_should_journal_data(inode)) {\n-\t\t\t\text4_wait_for_tail_page_commit(inode);\n-\t\t\t}\n-\t\t}\n+\t\tif (attr->ia_size > oldsize)\n+\t\t\terror = ext4_truncate_up(inode, oldsize, attr->ia_size);\n+\t\telse if (shrink)\n+\t\t\terror = ext4_truncate_down(inode, oldsize,\n+\t\t\t\t\t\t attr->ia_size, &orphan);\n+\t\tif (error)\n+\t\t\tgoto out_mmap_sem;\n \n \t\t/*\n \t\t * Truncate pagecache after we've waited for commit\n", "prefixes": [ "v3", "02/22" ] }