Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1534494

[PATCH 2/6] ubifs: Provide a custom llseek for directories

From Richard Weinberger <richard@nod.at>
Newsgroups linux.kernel
Subject [PATCH 2/6] ubifs: Provide a custom llseek for directories
Date 2016-12-01 23:10 +0100
Message-ID <sJHIe-2WG-31@gated-at.bofh.it> (permalink)
References <sJHId-2WG-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


When UBIFS is using 64bit cookies for directory offsets,
we have to support seeking that deep into direcoties.
Since generic_file_llseek() is uses sb->s_maxbytes it will
fail for use because on ubifs sb->s_maxbytes is the real maxmal
file size which can be much smaller than 64bit due to limitations
of the flash device.

Therefore provie a custom llseek operation.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/ubifs/dir.c         | 12 +++++++++++-
 fs/ubifs/ubifs-media.h |  6 ++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 7f01f3d2ac3b..883b2fdf51df 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1721,6 +1721,16 @@ static int ubifs_dir_open(struct inode *dir, struct file *file)
 	return 0;
 }
 
+static loff_t ubifs_dir_llseek(struct file *file, loff_t offset, int whence)
+{
+	struct inode *inode = file->f_mapping->host;
+
+	return generic_file_llseek_size(file, offset, whence,
+					(loff_t)UBIFS_S_KEY_HASH_MASK <<
+					UBIFS_DH_BITS | UBIFS_DH_MASK,
+					i_size_read(inode));
+}
+
 const struct inode_operations ubifs_dir_inode_operations = {
 	.lookup      = ubifs_lookup,
 	.create      = ubifs_create,
@@ -1741,7 +1751,7 @@ const struct inode_operations ubifs_dir_inode_operations = {
 };
 
 const struct file_operations ubifs_dir_operations = {
-	.llseek         = generic_file_llseek,
+	.llseek         = ubifs_dir_llseek,
 	.release        = ubifs_dir_release,
 	.read           = generic_read_dir,
 	.iterate_shared = ubifs_readdir,
diff --git a/fs/ubifs/ubifs-media.h b/fs/ubifs/ubifs-media.h
index e8c23c9d4f4a..5939776c7359 100644
--- a/fs/ubifs/ubifs-media.h
+++ b/fs/ubifs/ubifs-media.h
@@ -214,6 +214,12 @@ enum {
 #define UBIFS_S_KEY_HASH_MASK  UBIFS_S_KEY_BLOCK_MASK
 
 /*
+ * We use 32 bits for the double hash cookie.
+ */
+#define UBIFS_DH_MASK 0xffffffff
+#define UBIFS_DH_BITS 32
+
+/*
  * Key types.
  *
  * UBIFS_INO_KEY: inode node key
-- 
2.7.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] UBIFS NFS export support Richard Weinberger <richard@nod.at> - 2016-12-01 23:10 +0100
  [PATCH 2/6] ubifs: Provide a custom llseek for directories Richard Weinberger <richard@nod.at> - 2016-12-01 23:10 +0100
  [PATCH 4/6] ubifs: Maintain a parent pointer Richard Weinberger <richard@nod.at> - 2016-12-01 23:10 +0100
    Re: [PATCH 4/6] ubifs: Maintain a parent pointer Marcus Folkesson <marcus.folkesson@gmail.com> - 2016-12-02 10:40 +0100
      Re: [PATCH 4/6] ubifs: Maintain a parent pointer Richard Weinberger <richard@nod.at> - 2016-12-02 11:40 +0100

csiph-web