From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 6/8] fs: ext4: support files exceeding 4G
Date: Tue, 16 Feb 2021 21:02:06 +0100 [thread overview]
Message-ID: <20210216200208.5275-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20210216200208.5275-1-a.fatoum@pengutronix.de>
ext4 redefines directory ACL to hold the most-significant 32-bit of the
inode size for regular files. For directories, it can either be ACL or,
when using largedir, the most-significant 32-bit of the directory size.
Adapt the code take these upper 32-bit into consideration for
determining regular file size. For directories, behavior remains
unchanged as we neither support ACLs nor >= 4G directories
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
fs/ext4/ext4fs.c | 2 +-
fs/ext4/ext_barebox.c | 2 +-
fs/ext4/ext_common.h | 9 +++++++++
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index be643a448761..54349aad3f3f 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -55,7 +55,7 @@ loff_t ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
int log2blocksize = LOG2_EXT2_BLOCK_SIZE(node->data);
const int blockshift = log2blocksize + DISK_SECTOR_BITS;
const int blocksize = 1 << blockshift;
- unsigned int filesize = le32_to_cpu(node->inode.size);
+ loff_t filesize = ext4_isize(node);
ssize_t ret;
struct ext_filesystem *fs = node->data->fs;
diff --git a/fs/ext4/ext_barebox.c b/fs/ext4/ext_barebox.c
index a68a783e1c8a..8f318a49c008 100644
--- a/fs/ext4/ext_barebox.c
+++ b/fs/ext4/ext_barebox.c
@@ -221,7 +221,7 @@ struct inode *ext_get_inode(struct super_block *sb, int ino)
inode->i_ino = ino;
inode->i_mode = le16_to_cpu(node->inode.mode);
- inode->i_size = le32_to_cpu(node->inode.size);
+ inode->i_size = ext4_isize(node);
switch (inode->i_mode & S_IFMT) {
default:
diff --git a/fs/ext4/ext_common.h b/fs/ext4/ext_common.h
index 350cc6efe535..37575d2a1aea 100644
--- a/fs/ext4/ext_common.h
+++ b/fs/ext4/ext_common.h
@@ -232,4 +232,13 @@ struct ext2_data {
struct ext4fs_indir_block indir1, indir2, indir3;
};
+static inline loff_t ext4_isize(struct ext2fs_node *node)
+{
+ if (S_ISREG(le16_to_cpu(node->inode.mode)))
+ return ((loff_t)le32_to_cpu(node->inode.size_high) << 32) |
+ le32_to_cpu(node->inode.size);
+
+ return (loff_t) le32_to_cpu(node->inode.size);
+}
+
#endif
--
2.29.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-02-16 20:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-16 20:02 [PATCH 0/8] Support large files on larger ext4 partitions on larger still USB disks Ahmad Fatoum
2021-02-16 20:02 ` [PATCH 1/8] ext4: ext_common.h: drop declaration of never-defined part_offset Ahmad Fatoum
2021-02-16 20:02 ` [PATCH 2/8] fs: ext4: ext4fs.h: remove unused struct members of ext_filesystem Ahmad Fatoum
2021-02-16 20:02 ` [PATCH 3/8] block: use 64-bit types for sector offset and count on all platforms Ahmad Fatoum
2021-02-16 20:02 ` [PATCH 4/8] usb: storage: support USB disks up to 2TiB of size Ahmad Fatoum
2021-02-16 20:02 ` [PATCH 5/8] fs: ext4: use sector_t and loff_t where appropriate Ahmad Fatoum
2021-02-16 20:02 ` Ahmad Fatoum [this message]
2021-02-16 20:02 ` [PATCH 7/8] show_progress: change HASHES_PER_LINE from 65 to 64 to avoid division Ahmad Fatoum
2021-02-16 20:02 ` [PATCH 8/8] copy_file: fix progress bar for files larger than 2G Ahmad Fatoum
2021-02-18 8:24 ` [PATCH 0/8] Support large files on larger ext4 partitions on larger still USB disks Sascha Hauer
2021-02-19 13:56 ` Antony Pavlov
2021-02-25 10:49 ` Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210216200208.5275-7-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox