All of lore.kernel.org
 help / color / mirror / Atom feed
From: Evgeniy Dushistov <dushistov@mail.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [RFC] [PATCH 2/3]: ufs: track i_size
Date: Mon, 26 Jun 2006 17:48:36 +0400	[thread overview]
Message-ID: <20060626134836.GA8400@rain.homenetwork> (raw)

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 <dushistov@mail.ru>

---

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


             reply	other threads:[~2006-06-26 13:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-26 13:48 Evgeniy Dushistov [this message]
2006-06-26 18:54 ` [RFC] [PATCH 2/3]: ufs: track i_size Andrew Morton

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=20060626134836.GA8400@rain.homenetwork \
    --to=dushistov@mail.ru \
    --cc=akpm@osdl.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.