[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <174786678435.1385038.5869506710366055752.stgit@frogsfrogsfrogs>
Date: Wed, 21 May 2025 15:43:48 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 2/7] fuse2fs: implement dir seeking
From: Darrick J. Wong <djwong@...nel.org>
Report (fake) directory offsets to readdir so that libfuse can send
smaller datasets to the kernel.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
misc/fuse2fs.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index de5cfa3d776127..7ffe8a7e5dd4c0 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -3105,6 +3105,11 @@ struct readdir_iter {
void *buf;
ext2_filsys fs;
fuse_fill_dir_t func;
+
+ struct fuse2fs *ff;
+ unsigned int nr;
+ off_t startpos;
+ off_t dirpos;
};
static inline mode_t dirent_fmode(ext2_filsys fs,
@@ -3148,9 +3153,15 @@ static int op_readdir_iter(ext2_ino_t dir EXT2FS_ATTR((unused)),
};
int ret;
+ i->dirpos++;
+ if (i->startpos >= i->dirpos)
+ return 0;
+
+ dbg_printf(i->ff, "READDIR %u dirpos %llu\n", i->nr++,
+ (unsigned long long)i->dirpos);
memcpy(namebuf, dirent->name, dirent->name_len & 0xFF);
namebuf[dirent->name_len & 0xFF] = 0;
- ret = i->func(i->buf, namebuf, &stat, 0
+ ret = i->func(i->buf, namebuf, &stat, i->dirpos
#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
, 0
#endif
@@ -3163,7 +3174,7 @@ static int op_readdir_iter(ext2_ino_t dir EXT2FS_ATTR((unused)),
static int op_readdir(const char *path EXT2FS_ATTR((unused)),
void *buf, fuse_fill_dir_t fill_func,
- off_t offset EXT2FS_ATTR((unused)),
+ off_t offset,
struct fuse_file_info *fp
#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
, enum fuse_readdir_flags flags EXT2FS_ATTR((unused))
@@ -3175,13 +3186,18 @@ static int op_readdir(const char *path EXT2FS_ATTR((unused)),
struct fuse2fs_file_handle *fh =
(struct fuse2fs_file_handle *)(uintptr_t)fp->fh;
errcode_t err;
- struct readdir_iter i;
+ struct readdir_iter i = {
+ .ff = ff,
+ .dirpos = 0,
+ .startpos = offset,
+ };
int ret = 0;
FUSE2FS_CHECK_CONTEXT(ff);
i.fs = ff->fs;
FUSE2FS_CHECK_MAGIC(i.fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
+ dbg_printf(ff, "%s: ino=%d offset=%llu\n", __func__, fh->ino,
+ (unsigned long long)offset);
pthread_mutex_lock(&ff->bfl);
i.buf = buf;
i.func = fill_func;
Powered by blists - more mailing lists