From: npiggin@suse.de
To: linux-fsdevel@vger.kernel.org
Cc: hch@infradead.org, viro@zeniv.linux.org.uk, jack@suse.cz,
hugh.dickins@tiscali.co.uk
Subject: [patch 4/5] tmpfs: convert to use the new truncate convention
Date: Fri, 10 Jul 2009 17:30:32 +1000 [thread overview]
Message-ID: <20090710073231.048395467@suse.de> (raw)
In-Reply-To: 20090710073028.782561541@suse.de
[-- Attachment #1: tmpfs-new-truncate.patch --]
[-- Type: text/plain, Size: 3933 bytes --]
Cc: hugh.dickins@tiscali.co.uk
Signed-off-by: Nick Piggin <npiggin@suse.de>
---
fs/ext2/ext2.h | 1
fs/ext2/file.c | 2
fs/ext2/inode.c | 137 +++++++++++++++++++++++++++++++++++++++++++++-----------
mm/shmem.c | 35 +++++++-------
4 files changed, 131 insertions(+), 44 deletions(-)
Index: linux-2.6/mm/shmem.c
===================================================================
--- linux-2.6.orig/mm/shmem.c
+++ linux-2.6/mm/shmem.c
@@ -730,10 +730,11 @@ done2:
if (inode->i_mapping->nrpages && (info->flags & SHMEM_PAGEIN)) {
/*
* Call truncate_inode_pages again: racing shmem_unuse_inode
- * may have swizzled a page in from swap since vmtruncate or
- * generic_delete_inode did it, before we lowered next_index.
- * Also, though shmem_getpage checks i_size before adding to
- * cache, no recheck after: so fix the narrow window there too.
+ * may have swizzled a page in from swap since
+ * truncate_pagecache or generic_delete_inode did it, before we
+ * lowered next_index. Also, though shmem_getpage checks
+ * i_size before adding to cache, no recheck after: so fix the
+ * narrow window there too.
*
* Recalling truncate_inode_pages_range and unmap_mapping_range
* every time for punch_hole (which never got a chance to clear
@@ -763,11 +764,6 @@ done2:
}
}
-static void shmem_truncate(struct inode *inode)
-{
- shmem_truncate_range(inode, inode->i_size, (loff_t)-1);
-}
-
static int shmem_notify_change(struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = dentry->d_inode;
@@ -775,6 +771,8 @@ static int shmem_notify_change(struct de
int error;
if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE)) {
+ loff_t newsize = attr->ia_size;
+
if (attr->ia_size < inode->i_size) {
/*
* If truncating down to a partial page, then
@@ -783,9 +781,9 @@ static int shmem_notify_change(struct de
* truncate_partial_page cannnot miss it were
* it assigned to swap.
*/
- if (attr->ia_size & (PAGE_CACHE_SIZE-1)) {
+ if (newsize & (PAGE_CACHE_SIZE-1)) {
(void) shmem_getpage(inode,
- attr->ia_size>>PAGE_CACHE_SHIFT,
+ newsize >> PAGE_CACHE_SHIFT,
&page, SGP_READ, NULL);
if (page)
unlock_page(page);
@@ -797,13 +795,19 @@ static int shmem_notify_change(struct de
* if it's being fully truncated to zero-length: the
* nrpages check is efficient enough in that case.
*/
- if (attr->ia_size) {
+ if (newsize) {
struct shmem_inode_info *info = SHMEM_I(inode);
spin_lock(&info->lock);
info->flags &= ~SHMEM_PAGEIN;
spin_unlock(&info->lock);
}
}
+
+ error = simple_setsize(inode, newsize);
+ if (error)
+ return error;
+ shmem_truncate_range(inode, newsize, (loff_t)-1);
+ attr->ia_valid &= ~ATTR_SIZE;
}
error = inode_change_ok(inode, attr);
@@ -822,11 +826,11 @@ static void shmem_delete_inode(struct in
{
struct shmem_inode_info *info = SHMEM_I(inode);
- if (inode->i_op->truncate == shmem_truncate) {
+ if (inode->i_mapping->a_ops == &shmem_aops) {
truncate_inode_pages(inode->i_mapping, 0);
shmem_unacct_size(info->flags, inode->i_size);
inode->i_size = 0;
- shmem_truncate(inode);
+ shmem_truncate_range(inode, 0, (loff_t)-1);
if (!list_empty(&info->swaplist)) {
mutex_lock(&shmem_swaplist_mutex);
list_del_init(&info->swaplist);
@@ -2018,7 +2022,6 @@ static const struct inode_operations shm
};
static const struct inode_operations shmem_symlink_inode_operations = {
- .truncate = shmem_truncate,
.readlink = generic_readlink,
.follow_link = shmem_follow_link,
.put_link = shmem_put_link,
@@ -2438,7 +2441,7 @@ static const struct file_operations shme
};
static const struct inode_operations shmem_inode_operations = {
- .truncate = shmem_truncate,
+ .new_truncate = 1,
.setattr = shmem_notify_change,
.truncate_range = shmem_truncate_range,
#ifdef CONFIG_TMPFS_POSIX_ACL
next prev parent reply other threads:[~2009-07-10 7:34 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-10 7:30 [patch 0/5] new truncate sequence patchset npiggin
2009-07-10 7:30 ` [patch 1/5] fs: new truncate helpers npiggin
2009-07-10 7:30 ` [patch 2/5] fs: use " npiggin
2009-07-10 7:30 ` npiggin-l3A5Bk7waGM
2009-07-10 7:30 ` [patch 3/5] fs: introduce new truncate sequence npiggin
2009-07-10 7:30 ` npiggin [this message]
2009-07-10 7:30 ` [patch 5/5] ext2: convert to use the new truncate convention npiggin
2009-09-01 18:29 ` Jan Kara
2009-09-02 9:14 ` Nick Piggin
2009-09-02 11:14 ` Jan Kara
2009-07-10 9:33 ` [patch 1/3] fs: buffer_head writepage no invalidate Nick Piggin
2009-07-10 9:33 ` Nick Piggin
2009-07-10 9:34 ` [patch 2/3] fs: buffer_head writepage no zero Nick Piggin
2009-07-10 9:34 ` Nick Piggin
2009-07-10 11:46 ` Jan Kara
2009-07-10 11:46 ` Jan Kara
2009-07-13 6:54 ` Nick Piggin
2009-07-13 6:54 ` Nick Piggin
2009-07-10 9:35 ` [patch 3/3] fs: buffer_head page_lock i_size relax Nick Piggin
2009-07-10 9:35 ` Nick Piggin
2009-07-10 11:08 ` [patch 1/3] fs: buffer_head writepage no invalidate Jan Kara
2009-07-10 11:08 ` Jan Kara
2009-07-10 14:31 ` [patch 0/5] new truncate sequence patchset Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2009-08-16 10:25 [patch 0/5] new truncate sequence npiggin
2009-08-16 10:25 ` [patch 4/5] tmpfs: convert to use the new truncate convention npiggin
2009-08-16 18:38 ` Hugh Dickins
2009-08-17 7:32 ` Nick Piggin
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=20090710073231.048395467@suse.de \
--to=npiggin@suse.de \
--cc=hch@infradead.org \
--cc=hugh.dickins@tiscali.co.uk \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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.