From: npiggin@suse.de
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Subject: [patch 09/11] jfs: convert to use the new truncate convention.
Date: Fri, 21 Aug 2009 02:35:13 +1000 [thread overview]
Message-ID: <20090820164051.726730372@suse.de> (raw)
In-Reply-To: 20090820163504.131529718@suse.de
[-- Attachment #1: jfs-new-truncate.patch --]
[-- Type: text/plain, Size: 7029 bytes --]
Note I wasn't able to test jfs because the kernel wasn't mounting the
product of my mkfs.jfs for some reason.
Cc: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nick Piggin <npiggin@suse.de>
---
fs/jfs/acl.c | 12 ++---------
fs/jfs/file.c | 2 -
fs/jfs/inode.c | 56 +++++++++++++++++++++++++++++++++++++++++++----------
fs/jfs/jfs_inode.h | 5 ++--
fs/jfs/jfs_xtree.c | 2 -
fs/jfs/namei.c | 6 ++---
6 files changed, 57 insertions(+), 26 deletions(-)
Index: linux-2.6/fs/jfs/acl.c
===================================================================
--- linux-2.6.orig/fs/jfs/acl.c
+++ linux-2.6/fs/jfs/acl.c
@@ -216,20 +216,14 @@ int jfs_setattr(struct dentry *dentry, s
struct inode *inode = dentry->d_inode;
int rc;
- rc = inode_change_ok(inode, iattr);
+ rc = simple_setattr(dentry, iattr);
if (rc)
return rc;
- if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
- (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
- if (vfs_dq_transfer(inode, iattr))
- return -EDQUOT;
- }
-
- rc = inode_setattr(inode, iattr);
-
if (!rc && (iattr->ia_valid & ATTR_MODE))
rc = jfs_acl_chmod(inode);
+ mark_inode_dirty(inode);
+
return rc;
}
Index: linux-2.6/fs/jfs/file.c
===================================================================
--- linux-2.6.orig/fs/jfs/file.c
+++ linux-2.6/fs/jfs/file.c
@@ -89,7 +89,7 @@ static int jfs_release(struct inode *ino
}
const struct inode_operations jfs_file_inode_operations = {
- .truncate = jfs_truncate,
+ .new_truncate = 1,
.setxattr = jfs_setxattr,
.getxattr = jfs_getxattr,
.listxattr = jfs_listxattr,
Index: linux-2.6/fs/jfs/inode.c
===================================================================
--- linux-2.6.orig/fs/jfs/inode.c
+++ linux-2.6/fs/jfs/inode.c
@@ -297,8 +297,33 @@ static int jfs_write_begin(struct file *
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
{
- return nobh_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+ int ret;
+
+ ret = nobh_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
jfs_get_block);
+ if (ret < 0) {
+ struct inode *inode = mapping->host;
+ loff_t isize = inode->i_size;
+ if (pos + len > isize)
+ jfs_truncate_blocks(inode, isize);
+ }
+ return ret;
+}
+
+static int jfs_write_end(struct file *file, struct address_space *mapping,
+ loff_t pos, unsigned len, unsigned copied,
+ struct page *page, void *fsdata)
+{
+ int ret;
+
+ ret = nobh_write_end(file, mapping, pos, len, copied, page, fsdata);
+ if (ret < len) {
+ struct inode *inode = mapping->host;
+ loff_t isize = inode->i_size;
+ if (pos + len > isize)
+ jfs_truncate_blocks(inode, isize);
+ }
+ return ret;
}
static sector_t jfs_bmap(struct address_space *mapping, sector_t block)
@@ -311,9 +336,13 @@ static ssize_t jfs_direct_IO(int rw, str
{
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host;
+ ssize_t ret;
- return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
+ ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
offset, nr_segs, jfs_get_block, NULL);
+ if (ret < 0)
+ jfs_truncate_blocks(inode, inode->i_size);
+ return ret;
}
const struct address_space_operations jfs_aops = {
@@ -323,16 +352,16 @@ const struct address_space_operations jf
.writepages = jfs_writepages,
.sync_page = block_sync_page,
.write_begin = jfs_write_begin,
- .write_end = nobh_write_end,
+ .write_end = jfs_write_end,
.bmap = jfs_bmap,
.direct_IO = jfs_direct_IO,
};
/*
- * Guts of jfs_truncate. Called with locks already held. Can be called
+ * Guts of jfs_truncate_blocks. Called with locks already held. Can be called
* with directory for truncating directory index table.
*/
-void jfs_truncate_nolock(struct inode *ip, loff_t length)
+void jfs_truncate_blocks_nolock(struct inode *ip, loff_t length)
{
loff_t newsize;
tid_t tid;
@@ -372,13 +401,20 @@ void jfs_truncate_nolock(struct inode *i
} while (newsize > length); /* Truncate isn't always atomic */
}
-void jfs_truncate(struct inode *ip)
+void jfs_truncate_blocks(struct inode *ip, loff_t offset)
{
- jfs_info("jfs_truncate: size = 0x%lx", (ulong) ip->i_size);
-
- nobh_truncate_page(ip->i_mapping, ip->i_size, jfs_get_block);
+ jfs_info("jfs_truncate: size = 0x%lx", (ulong) offset);
IWRITE_LOCK(ip, RDWRLOCK_NORMAL);
- jfs_truncate_nolock(ip, ip->i_size);
+ jfs_truncate_blocks_nolock(ip, offset);
IWRITE_UNLOCK(ip);
}
+
+void jfs_setsize(struct inode *ip, loff_t offset)
+{
+ simple_setsize(ip, offset);
+
+ nobh_truncate_page(ip->i_mapping, offset, jfs_get_block);
+
+ jfs_truncate_blocks(ip, offset);
+}
Index: linux-2.6/fs/jfs/jfs_inode.h
===================================================================
--- linux-2.6.orig/fs/jfs/jfs_inode.h
+++ linux-2.6/fs/jfs/jfs_inode.h
@@ -29,8 +29,9 @@ extern int jfs_commit_inode(struct inode
extern int jfs_write_inode(struct inode*, int);
extern void jfs_delete_inode(struct inode *);
extern void jfs_dirty_inode(struct inode *);
-extern void jfs_truncate(struct inode *);
-extern void jfs_truncate_nolock(struct inode *, loff_t);
+extern void jfs_truncate_blocks(struct inode *, loff_t);
+extern void jfs_truncate_blocks_nolock(struct inode *, loff_t);
+extern void jfs_setsize(struct inode *, loff_t);
extern void jfs_free_zero_link(struct inode *);
extern struct dentry *jfs_get_parent(struct dentry *dentry);
extern void jfs_get_inode_flags(struct jfs_inode_info *);
Index: linux-2.6/fs/jfs/jfs_xtree.c
===================================================================
--- linux-2.6.orig/fs/jfs/jfs_xtree.c
+++ linux-2.6/fs/jfs/jfs_xtree.c
@@ -3132,7 +3132,7 @@ void xtInitRoot(tid_t tid, struct inode
* note:
* PWMAP:
* 1. truncate (non-COMMIT_NOLINK file)
- * by jfs_truncate() or jfs_open(O_TRUNC):
+ * by jfs_setsize() or jfs_open(O_TRUNC):
* xtree is updated;
* 2. truncate index table of directory when last entry removed
* map update via tlock at commit time;
Index: linux-2.6/fs/jfs/namei.c
===================================================================
--- linux-2.6.orig/fs/jfs/namei.c
+++ linux-2.6/fs/jfs/namei.c
@@ -435,7 +435,7 @@ static int jfs_rmdir(struct inode *dip,
*/
if (test_cflag(COMMIT_Stale, dip)) {
if (dip->i_size > 1)
- jfs_truncate_nolock(dip, 0);
+ jfs_truncate_blocks_nolock(dip, 0);
clear_cflag(COMMIT_Stale, dip);
}
@@ -586,7 +586,7 @@ static int jfs_unlink(struct inode *dip,
*/
if (test_cflag(COMMIT_Stale, dip)) {
if (dip->i_size > 1)
- jfs_truncate_nolock(dip, 0);
+ jfs_truncate_blocks_nolock(dip, 0);
clear_cflag(COMMIT_Stale, dip);
}
@@ -1327,7 +1327,7 @@ static int jfs_rename(struct inode *old_
*/
if (test_cflag(COMMIT_Stale, old_dir)) {
if (old_dir->i_size > 1)
- jfs_truncate_nolock(old_dir, 0);
+ jfs_truncate_blocks_nolock(old_dir, 0);
clear_cflag(COMMIT_Stale, old_dir);
}
next prev parent reply other threads:[~2009-08-20 16:42 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 16:35 [patch 00/11] new truncate sequence npiggin
2009-08-20 16:35 ` [patch 01/11] fs: new truncate helpers npiggin
2009-08-26 7:38 ` Artem Bityutskiy
2009-09-07 7:33 ` Nick Piggin
2009-09-07 7:48 ` Artem Bityutskiy
2009-08-20 16:35 ` [patch 02/11] fs: use " npiggin
2009-08-20 16:35 ` npiggin-l3A5Bk7waGM
2009-08-20 16:35 ` [patch 03/11] fs: introduce new truncate sequence npiggin
2009-08-26 7:40 ` Artem Bityutskiy
2009-08-20 16:35 ` [patch 04/11] fs: convert simple fs to new truncate npiggin
2009-08-20 16:35 ` [patch 05/11] tmpfs: convert to use the new truncate convention npiggin
2009-08-20 16:35 ` [patch 06/11] ext2: " npiggin
2009-08-21 13:42 ` Jan Kara
2009-08-21 14:06 ` Jan Kara
2009-08-24 5:30 ` [patch] ext2: convert to use the new truncate convention fix Nick Piggin
2009-08-20 16:35 ` [patch 07/11] fat: convert to use the new truncate convention npiggin
2009-08-20 16:35 ` [patch 08/11] btrfs: " npiggin
2009-08-20 16:35 ` npiggin
2009-08-20 16:35 ` npiggin [this message]
2009-08-20 16:35 ` [patch 10/11] udf: " npiggin
2009-08-21 14:22 ` Jan Kara
2009-08-24 5:33 ` Nick Piggin
2009-08-20 16:35 ` [patch 11/11] minix: " npiggin
2009-09-09 7:11 ` [patch 00/11] new truncate sequence Artem Bityutskiy
2009-09-22 15:04 ` Al Viro
2009-09-22 20:00 ` Christoph Hellwig
2009-09-22 21:51 ` Al Viro
2009-09-22 23:27 ` Al Viro
2009-09-22 23:58 ` Al Viro
2009-09-23 2:29 ` Al Viro
2009-09-27 19:50 ` Nick Piggin
2009-12-07 12:49 ` Nick Piggin
2009-12-07 22:46 ` Tyler Hicks
2009-09-22 20:53 ` [PATCH 12/n] kill spurious reference to vmtruncate Christoph Hellwig
2009-09-22 20:54 ` [PATCH 13/n] xfs: new truncate sequence Christoph Hellwig
2009-09-22 20:54 ` Christoph Hellwig
2009-09-22 20:55 ` [PATCH 14/n] sysv: " Christoph Hellwig
2009-09-22 20:56 ` [PATCH 15/n] ntfs: " Christoph Hellwig
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=20090820164051.726730372@suse.de \
--to=npiggin@suse.de \
--cc=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=shaggy@linux.vnet.ibm.com \
/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.