[Ocfs2-commits] mfasheh commits r2381 - in trunk: . fs/ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Jun 9 13:42:50 CDT 2005
Author: mfasheh
Signed-off-by: manish
Signed-off-by: zab
Date: 2005-06-09 13:42:48 -0500 (Thu, 09 Jun 2005)
New Revision: 2381
Modified:
trunk/README
trunk/fs/ocfs2/file.c
Log:
* sendfile support for OCFS2
Signed-off-by: manish
Signed-off-by: zab
Modified: trunk/README
===================================================================
--- trunk/README 2005-06-09 01:24:08 UTC (rev 2380)
+++ trunk/README 2005-06-09 18:42:48 UTC (rev 2381)
@@ -31,7 +31,8 @@
- extended attributes
- readonly mount
- shared writeable mmap
- - sendfile (loopback mounts don't currently work because of this)
+ - loopback is supported, but data written will not
+ be cluster coherent.
Mount options
=============
Modified: trunk/fs/ocfs2/file.c
===================================================================
--- trunk/fs/ocfs2/file.c 2005-06-09 01:24:08 UTC (rev 2380)
+++ trunk/fs/ocfs2/file.c 2005-06-09 18:42:48 UTC (rev 2381)
@@ -329,9 +329,56 @@
return ret;
}
+static ssize_t ocfs2_file_sendfile(struct file *in_file,
+ loff_t *ppos,
+ size_t count,
+ read_actor_t actor,
+ void *target)
+{
+ int ret;
+ struct inode *inode = in_file->f_mapping->host;
+
+ mlog_entry("inode %"MLFu64", ppos %"MLFu64", count = %u\n",
+ OCFS2_I(inode)->ip_blkno, (long long) *ppos,
+ (unsigned int) count);
+
+ /* Obviously, there is no user buffer to worry about here --
+ * this simplifies locking, so no need to walk vmas a la
+ * read/write. We take a simple set of cluster locks against
+ * the inode and call generic_file_sendfile. */
+ ret = ocfs2_meta_lock(inode, NULL, NULL, 0);
+ if (ret < 0) {
+ mlog_errno(ret);
+ goto bail;
+ }
+
+ ret = ocfs2_data_lock(inode, 0);
+ if (ret < 0) {
+ mlog_errno(ret);
+ goto bail_unlock_meta;
+ }
+
+ down_read(&OCFS2_I(inode)->ip_alloc_sem);
+
+ ret = generic_file_sendfile(in_file, ppos, count, actor, target);
+ if (ret < 0)
+ mlog_errno(ret);
+
+ up_read(&OCFS2_I(inode)->ip_alloc_sem);
+
+ ocfs2_data_unlock(inode, 0);
+bail_unlock_meta:
+ ocfs2_meta_unlock(inode, 0);
+
+bail:
+ mlog_exit(ret);
+ return ret;
+}
+
struct file_operations ocfs2_fops = {
.read = ocfs2_file_read,
.write = ocfs2_file_write,
+ .sendfile = ocfs2_file_sendfile,
.mmap = ocfs2_mmap,
.fsync = ocfs2_sync_file,
.release = ocfs2_file_release,
More information about the Ocfs2-commits
mailing list