From: Valerie Aurora <val@versity.com>
To: rpdfs-devel@lists.linux.dev
Subject: [PATCH 5/6] rpdfs: add rpdfs_write_iter/rpdfs_read_iter
Date: Thu, 7 May 2026 15:21:52 +0200 [thread overview]
Message-ID: <20260507132153.1161324-6-val@versity.com> (raw)
In-Reply-To: <20260507132153.1161324-1-val@versity.com>
Implement write_iter/read_iter with generic functions.
Signed-off-by: Valerie Aurora <val@versity.com>
---
fs/rpdfs/file.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/fs/rpdfs/file.c b/fs/rpdfs/file.c
index e8918e38b3fe..060de1070963 100644
--- a/fs/rpdfs/file.c
+++ b/fs/rpdfs/file.c
@@ -1,9 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/kernel.h>
#include <linux/fs.h>
+#include <linux/slab.h>
#include "file.h"
#include "inode.h"
+#include "pr.h"
static loff_t rpdfs_file_llseek(struct file *file, loff_t offset, int whence)
{
@@ -22,6 +25,60 @@ static loff_t rpdfs_file_llseek(struct file *file, loff_t offset, int whence)
return ret;
}
+static ssize_t rpdfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+ struct file *file = iocb->ki_filp;
+ struct inode *inode = file->f_mapping->host;
+ struct rpdfs_fs_info *rfi = RPDFS_INODE_FS(inode);
+ struct rpdfs_block_handle *hnd = NULL;
+ struct rpdfs_transaction txn = RPDFS_INIT_TXN;
+ ssize_t ret;
+
+ rpdfs_prd("ino %llu count %lu pos %lu",
+ rpdfs_inode_ino(inode), iov_iter_count(from), (unsigned long) iocb->ki_pos);
+
+ inode_lock(inode);
+
+ ret = rpdfs_inode_acquire(rfi, &txn, inode, &hnd, RBAF_WRITE);
+ if (ret < 0)
+ goto out;
+
+ ret = generic_write_checks(iocb, from);
+ if (ret <= 0)
+ goto out;
+
+ ret = __generic_file_write_iter(iocb, from);
+out:
+ rpdfs_block_release(rfi, &hnd);
+ inode_unlock(inode);
+
+ if (ret > 0)
+ ret = generic_write_sync(iocb, ret);
+
+ return ret;
+}
+
+static ssize_t rpdfs_file_read_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+ struct file *file = iocb->ki_filp;
+ struct inode *inode = file_inode(file);
+ struct rpdfs_fs_info *rfi = RPDFS_INODE_FS(inode);
+ struct rpdfs_block_handle *hnd = NULL;
+ int ret;
+
+ ret = rpdfs_inode_acquire(rfi, NULL, inode, &hnd, 0);
+ if (ret < 0)
+ goto out;
+
+ rpdfs_prd("ino %llu count %lu pos %lu",
+ rpdfs_inode_ino(inode), iov_iter_count(from), (unsigned long) iocb->ki_pos);
+
+ ret = generic_file_read_iter(iocb, from);
+out:
+ rpdfs_block_release(rfi, &hnd);
+ return ret;
+}
+
const struct inode_operations rpdfs_file_iops = {
.getattr = rpdfs_getattr,
.setattr = rpdfs_setattr,
@@ -29,4 +86,6 @@ const struct inode_operations rpdfs_file_iops = {
const struct file_operations rpdfs_file_fops = {
.llseek = rpdfs_file_llseek,
+ .write_iter = rpdfs_file_write_iter,
+ .read_iter = rpdfs_file_read_iter,
};
--
2.49.0
next prev parent reply other threads:[~2026-05-07 13:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 13:21 [PATCH 0/6] File data read/write version 2 Valerie Aurora
2026-05-07 13:21 ` [PATCH 1/6] rpdfs: add rpdfs_file_llseek Valerie Aurora
2026-05-07 13:21 ` [PATCH 2/6] rpdfs: add inode change debugging routine Valerie Aurora
2026-05-07 13:21 ` [PATCH 3/6] rpdfs: add basic file data initialization Valerie Aurora
2026-05-07 13:21 ` [PATCH 4/6] rpdfs: add file data allocation and lookup routines Valerie Aurora
2026-05-07 13:21 ` Valerie Aurora [this message]
2026-05-07 13:21 ` [PATCH 6/6] rpdfs: add read_folio, dirty_folio, write_begin, write_end Valerie Aurora
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=20260507132153.1161324-6-val@versity.com \
--to=val@versity.com \
--cc=rpdfs-devel@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.