[RFC] [PATCH 2/3]: ufs: track i_size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To make possible proper work of `ufs_truncate'(see the next patch),
I need to know old size of file in` ufs_truncate',
but for some unknown for me reason VFS layer doesn't tell
old size to file system, or at least I don't find way to get
this information. 
So I have to add per each inode `loff_t' field and update it
in
- alloc inode
- read inode
- commit write
- truncate(see the next patch)
is this right way to know "old size" in truncate method?

Signed-off-by: Evgeniy Dushistov <[email protected]>

---

Index: linux-2.6.17-mm2/fs/ufs/ialloc.c
===================================================================
--- linux-2.6.17-mm2.orig/fs/ufs/ialloc.c
+++ linux-2.6.17-mm2/fs/ufs/ialloc.c
@@ -265,6 +265,7 @@ cg_found:
 	ufsi->i_osync = 0;
 	ufsi->i_oeftflag = 0;
 	ufsi->i_dir_start_lookup = 0;
+	ufsi->i_size = 0;
 	memset(&ufsi->i_u1, 0, sizeof(ufsi->i_u1));
 
 	insert_inode_hash(inode);
Index: linux-2.6.17-mm2/fs/ufs/inode.c
===================================================================
--- linux-2.6.17-mm2.orig/fs/ufs/inode.c
+++ linux-2.6.17-mm2/fs/ufs/inode.c
@@ -574,12 +574,25 @@ static sector_t ufs_bmap(struct address_
 {
 	return generic_block_bmap(mapping,block,ufs_getfrag_block);
 }
+
+/*
+ * we have to update our internal i_size holder,
+ * because of we want know old size in truncate
+ */
+static int ufs_commit_write(struct file *file, struct page *page,
+			    unsigned from, unsigned to)
+{
+	UFS_I(page->mapping->host)->i_size =
+		((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
+	return generic_commit_write(file, page, from, to);
+}
+
 const struct address_space_operations ufs_aops = {
 	.readpage = ufs_readpage,
 	.writepage = ufs_writepage,
 	.sync_page = block_sync_page,
 	.prepare_write = ufs_prepare_write,
-	.commit_write = generic_commit_write,
+	.commit_write = ufs_commit_write,
 	.bmap = ufs_bmap
 };
 
@@ -738,6 +751,7 @@ void ufs_read_inode(struct inode * inode
 		(inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift;
 	ufsi->i_dir_start_lookup = 0;
 	ufsi->i_osync = 0;
+	ufsi->i_size = inode->i_size;
 
 	ufs_set_inode_ops(inode);
 
Index: linux-2.6.17-mm2/include/linux/ufs_fs_i.h
===================================================================
--- linux-2.6.17-mm2.orig/include/linux/ufs_fs_i.h
+++ linux-2.6.17-mm2/include/linux/ufs_fs_i.h
@@ -28,6 +28,7 @@ struct ufs_inode_info {
 	__u16	i_osync;
 	__u32	i_lastfrag;
 	__u32   i_dir_start_lookup;
+	loff_t	i_size;
 	struct inode vfs_inode;
 };
 


-- 
/Evgeniy

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux