[Patch 08/18] fs/logfs/file.c

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jörn
Date: Sunday, June 3, 2007 - 11:45 am

--- /dev/null	2007-03-13 19:15:28.862769062 +0100
+++ linux-2.6.21logfs/fs/logfs/file.c	2007-06-03 19:55:14.000000000 +0200
@@ -0,0 +1,75 @@
+/*
+ * fs/logfs/file.c	- prepare_write, commit_write and friends
+ *
+ * As should be obvious for Linux kernel code, license is GPLv2
+ *
+ * Copyright (c) 2005-2007 Joern Engel
+ */
+#include "logfs.h"
+
+static int logfs_prepare_write(struct file *file, struct page *page,
+		unsigned start, unsigned end)
+{
+	if (PageUptodate(page))
+		return 0;
+
+	if ((start == 0) && (end == PAGE_CACHE_SIZE))
+		return 0;
+
+	return logfs_readpage_nolock(page);
+}
+
+static int logfs_commit_write(struct file *file, struct page *page,
+		unsigned start, unsigned end)
+{
+	struct inode *inode = page->mapping->host;
+	pgoff_t index = page->index;
+	void *buf;
+	int ret;
+
+	BUG_ON(PAGE_CACHE_SIZE != inode->i_sb->s_blocksize);
+	BUG_ON(page->index > I3_BLOCKS);
+
+	if (start == end)
+		return 0; /* FIXME: do we need to update inode? */
+
+	if (i_size_read(inode) < (index << PAGE_CACHE_SHIFT) + end) {
+		i_size_write(inode, (index << PAGE_CACHE_SHIFT) + end);
+		mark_inode_dirty_sync(inode);
+	}
+
+	buf = kmap(page);
+	ret = logfs_write_buf(inode, index, buf);
+	kunmap(page);
+	return ret;
+}
+
+static int logfs_readpage(struct file *file, struct page *page)
+{
+	int ret;
+
+	ret = logfs_readpage_nolock(page);
+	unlock_page(page);
+	return ret;
+}
+
+const struct inode_operations logfs_reg_iops = {
+	.truncate	= logfs_truncate,
+};
+
+const struct file_operations logfs_reg_fops = {
+	.aio_read	= generic_file_aio_read,
+	.aio_write	= generic_file_aio_write,
+	.llseek		= generic_file_llseek,
+	.mmap		= generic_file_readonly_mmap,
+	.open		= generic_file_open,
+	.read		= do_sync_read,
+	.write		= do_sync_write,
+};
+
+const struct address_space_operations logfs_reg_aops = {
+	.commit_write	= logfs_commit_write,
+	.prepare_write	= logfs_prepare_write,
+	.readpage	= logfs_readpage,
+	.set_page_dirty	= __set_page_dirty_nobuffers,
+};
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
LogFS take four, Jörn, (Sun Jun 3, 11:38 am)
[Patch 01/18] fs/Kconfig, Jörn, (Sun Jun 3, 11:40 am)
[Patch 02/18] fs/Makefile, Jörn, (Sun Jun 3, 11:40 am)
[Patch 03/18] fs/logfs/Makefile, Jörn, (Sun Jun 3, 11:41 am)
[Patch 04/18] include/linux/logfs.h, Jörn, (Sun Jun 3, 11:42 am)
[Patch 05/18] fs/logfs/logfs.h, Jörn, (Sun Jun 3, 11:43 am)
[Patch 06/18] fs/logfs/compr.c, Jörn, (Sun Jun 3, 11:43 am)
[Patch 07/18] fs/logfs/dir.c, Jörn, (Sun Jun 3, 11:44 am)
[Patch 08/18] fs/logfs/file.c, Jörn, (Sun Jun 3, 11:45 am)
[Patch 09/18] fs/logfs/gc.c, Jörn, (Sun Jun 3, 11:46 am)
[Patch 10/18] fs/logfs/inode.c, Jörn, (Sun Jun 3, 11:46 am)
[Patch 11/18] fs/logfs/journal.c, Jörn, (Sun Jun 3, 11:47 am)
[Patch 12/18] fs/logfs/memtree.c, Jörn, (Sun Jun 3, 11:47 am)
[Patch 13/18] fs/logfs/readwrite.c, Jörn, (Sun Jun 3, 11:48 am)
[Patch 14/18] fs/logfs/segment.c, Jörn, (Sun Jun 3, 11:48 am)
[Patch 15/18] fs/logfs/super.c, Jörn, (Sun Jun 3, 11:49 am)
[Patch 16/18] fs/logfs/progs/fsck.c, Jörn, (Sun Jun 3, 11:50 am)
[Patch 17/18] fs/logfs/progs/mkfs.c, Jörn, (Sun Jun 3, 11:50 am)
[Patch 18/18] fs/logfs/Locking, Jörn, (Sun Jun 3, 11:51 am)
Re: LogFS take four, Jan-Benedict Glaw, (Sun Jun 3, 12:17 pm)
Re: LogFS take four, Jörn, (Sun Jun 3, 12:19 pm)
Re: [Patch 04/18] include/linux/logfs.h, Arnd Bergmann, (Sun Jun 3, 2:42 pm)
Re: [Patch 05/18] fs/logfs/logfs.h, Arnd Bergmann, (Sun Jun 3, 2:50 pm)
Re: [Patch 06/18] fs/logfs/compr.c, Arnd Bergmann, (Sun Jun 3, 2:58 pm)
Re: [Patch 09/18] fs/logfs/gc.c, Arnd Bergmann, (Sun Jun 3, 3:07 pm)
Re: LogFS take four, Arnd Bergmann, (Sun Jun 3, 3:18 pm)
Re: [Patch 14/18] fs/logfs/segment.c, Arnd Bergmann, (Sun Jun 3, 3:21 pm)
Re: [Patch 05/18] fs/logfs/logfs.h, Jan Engelhardt, (Mon Jun 4, 1:17 am)
Re: [Patch 06/18] fs/logfs/compr.c, Jörn, (Mon Jun 4, 1:54 am)
Re: [Patch 09/18] fs/logfs/gc.c, Jörn, (Mon Jun 4, 2:01 am)
Re: LogFS take four, Jörn, (Mon Jun 4, 2:05 am)
Re: [Patch 14/18] fs/logfs/segment.c, Jörn, (Mon Jun 4, 2:07 am)
Re: [Patch 05/18] fs/logfs/logfs.h, Jörn, (Mon Jun 4, 2:11 am)
Re: [Patch 04/18] include/linux/logfs.h, Jörn, (Mon Jun 4, 2:12 am)
Re: [Patch 04/18] include/linux/logfs.h, David Woodhouse, (Mon Jun 4, 6:38 am)
Re: [Patch 06/18] fs/logfs/compr.c, David Woodhouse, (Mon Jun 4, 6:53 am)
Re: [Patch 04/18] include/linux/logfs.h, Jörn, (Mon Jun 4, 7:02 am)
Re: [Patch 04/18] include/linux/logfs.h, Segher Boessenkool, (Tue Jun 5, 8:49 am)
Re: [Patch 04/18] include/linux/logfs.h, David Woodhouse, (Tue Jun 5, 8:53 am)
Re: [Patch 04/18] include/linux/logfs.h, Segher Boessenkool, (Tue Jun 5, 11:49 am)
Re: [Patch 04/18] include/linux/logfs.h, Bill Davidsen, (Tue Jun 5, 1:39 pm)
Re: [Patch 04/18] include/linux/logfs.h, David Woodhouse, (Wed Jun 6, 1:50 am)
Re: [Patch 04/18] include/linux/logfs.h, Andreas Schwab, (Wed Jun 6, 1:59 am)
Re: [Patch 05/18] fs/logfs/logfs.h, Jörn, (Wed Jun 6, 4:29 am)
Re: [Patch 05/18] fs/logfs/logfs.h, Paulo Marques, (Wed Jun 6, 4:29 am)
Re: [Patch 04/18] include/linux/logfs.h, Arnd Bergmann, (Wed Jun 6, 5:42 am)
Re: [Patch 15/18] fs/logfs/super.c, Arnd Bergmann, (Sun Jun 10, 9:27 am)
Re: [Patch 10/18] fs/logfs/inode.c, Arnd Bergmann, (Sun Jun 10, 10:24 am)
Re: [Patch 15/18] fs/logfs/super.c, Jörn, (Sun Jun 10, 10:38 am)
Re: [Patch 10/18] fs/logfs/inode.c, Jörn, (Sun Jun 10, 10:40 am)
Re: [Patch 15/18] fs/logfs/super.c, Arnd Bergmann, (Sun Jun 10, 11:33 am)
Re: [Patch 15/18] fs/logfs/super.c, Jörn, (Sun Jun 10, 12:10 pm)
Re: [Patch 15/18] fs/logfs/super.c, Willy Tarreau, (Sun Jun 10, 12:20 pm)
Re: [Patch 10/18] fs/logfs/inode.c, Jörn, (Mon Jun 11, 4:28 pm)
Re: [Patch 10/18] fs/logfs/inode.c, Arnd Bergmann, (Mon Jun 11, 4:51 pm)
Re: [Patch 10/18] fs/logfs/inode.c, Jörn, (Mon Jun 11, 4:57 pm)
Re: LogFS take four, Evgeniy Polyakov, (Fri Jun 15, 1:37 am)
Re: [Patch 07/18] fs/logfs/dir.c, Evgeniy Polyakov, (Fri Jun 15, 1:59 am)
Re: [Patch 09/18] fs/logfs/gc.c, Evgeniy Polyakov, (Fri Jun 15, 2:03 am)
Re: LogFS take four, Jörn, (Fri Jun 15, 4:10 am)
Re: [Patch 09/18] fs/logfs/gc.c, Jörn, (Fri Jun 15, 4:14 am)
Re: [Patch 07/18] fs/logfs/dir.c, Jörn, (Fri Jun 15, 4:57 am)
Re: [Patch 09/18] fs/logfs/gc.c, Evgeniy Polyakov, (Fri Jun 15, 6:03 am)