[JFFS2] Use ALLOC_DELETION priority for truncation to zero length
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Fri Feb 29 12:59:01 EST 2008
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=dd919660aacdf4adfcd279556aa03e595f7f0fc2
Commit: dd919660aacdf4adfcd279556aa03e595f7f0fc2
Parent: b28ba9fa0154f78f3d36f5ae9a42f7bb01663cca
Author: David Woodhouse <dwmw2 at infradead.org>
AuthorDate: Mon Feb 25 15:25:25 2008 +0000
Committer: David Woodhouse <dwmw2 at infradead.org>
CommitDate: Mon Feb 25 15:25:25 2008 +0000
[JFFS2] Use ALLOC_DELETION priority for truncation to zero length
This is going to obsolete all previous nodes, so treat it as deletion.
Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
fs/jffs2/fs.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 3f49562..9dafb53 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -36,6 +36,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
unsigned int ivalid;
uint32_t alloclen;
int ret;
+ int alloc_type = ALLOC_NORMAL;
D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino));
@@ -115,6 +116,10 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
ri->compr = JFFS2_COMPR_ZERO;
ri->dsize = cpu_to_je32(iattr->ia_size - inode->i_size);
ri->offset = cpu_to_je32(inode->i_size);
+ } else if (ivalid & ATTR_SIZE && !iattr->ia_size) {
+ /* For truncate-to-zero, treat it as deletion because
+ it'll always be obsoleting all previous nodes */
+ alloc_type = ALLOC_DELETION;
}
ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
if (mdatalen)
@@ -122,7 +127,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
else
ri->data_crc = cpu_to_je32(0);
- new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, ALLOC_NORMAL);
+ new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, alloc_type);
if (S_ISLNK(inode->i_mode))
kfree(mdata);
More information about the linux-mtd-cvs
mailing list