get rid of cont_write_begin_newtrunc
authorChristoph Hellwig <hch@lst.de>
Fri, 4 Jun 2010 09:29:55 +0000 (11:29 +0200)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 9 Aug 2010 20:47:31 +0000 (16:47 -0400)
Move the call to vmtruncate to get rid of accessive blocks to the callers
in preparation of the new truncate sequence and rename the non-truncating
version to cont_write_begin.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/adfs/inode.c
fs/affs/file.c
fs/buffer.c
fs/fat/inode.c
fs/hfs/inode.c
fs/hfsplus/inode.c
fs/hpfs/file.c
fs/qnx4/inode.c
include/linux/buffer_head.h

index 6f850b06ab625e7e106a6c149f7449c223407665..b3dec193036bd95f25841eec930b845e77eefdf4 100644 (file)
@@ -50,10 +50,19 @@ static int adfs_write_begin(struct file *file, struct address_space *mapping,
                        loff_t pos, unsigned len, unsigned flags,
                        struct page **pagep, void **fsdata)
 {
+       int ret;
+
        *pagep = NULL;
-       return cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+       ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
                                adfs_get_block,
                                &ADFS_I(mapping->host)->mmu_private);
+       if (unlikely(ret)) {
+               loff_t isize = mapping->host->i_size;
+               if (pos + len > isize)
+                       vmtruncate(mapping->host, isize);
+       }
+
+       return ret;
 }
 
 static sector_t _adfs_bmap(struct address_space *mapping, sector_t block)
index 322710c3eedf25c35ca4ca5888e4c2ab96bed728..c4a9875bd1a60520c682bed74f7a27bc3d2e1da0 100644 (file)
@@ -406,10 +406,19 @@ static int affs_write_begin(struct file *file, struct address_space *mapping,
                        loff_t pos, unsigned len, unsigned flags,
                        struct page **pagep, void **fsdata)
 {
+       int ret;
+
        *pagep = NULL;
-       return cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+       ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
                                affs_get_block,
                                &AFFS_I(mapping->host)->mmu_private);
+       if (unlikely(ret)) {
+               loff_t isize = mapping->host->i_size;
+               if (pos + len > isize)
+                       vmtruncate(mapping->host, isize);
+       }
+
+       return ret;
 }
 
 static sector_t _affs_bmap(struct address_space *mapping, sector_t block)
index 559daf76bca44a88f32c442a0422ba0c3f1bc091..14529ec759b963a23dd38b44c20aa3c820bf8d78 100644 (file)
@@ -2351,7 +2351,7 @@ out:
  * For moronic filesystems that do not allow holes in file.
  * We may have to extend the file.
  */
-int cont_write_begin_newtrunc(struct file *file, struct address_space *mapping,
+int cont_write_begin(struct file *file, struct address_space *mapping,
                        loff_t pos, unsigned len, unsigned flags,
                        struct page **pagep, void **fsdata,
                        get_block_t *get_block, loff_t *bytes)
@@ -2377,25 +2377,6 @@ int cont_write_begin_newtrunc(struct file *file, struct address_space *mapping,
 out:
        return err;
 }
-EXPORT_SYMBOL(cont_write_begin_newtrunc);
-
-int cont_write_begin(struct file *file, struct address_space *mapping,
-                       loff_t pos, unsigned len, unsigned flags,
-                       struct page **pagep, void **fsdata,
-                       get_block_t *get_block, loff_t *bytes)
-{
-       int ret;
-
-       ret = cont_write_begin_newtrunc(file, mapping, pos, len, flags,
-                                       pagep, fsdata, get_block, bytes);
-       if (unlikely(ret)) {
-               loff_t isize = mapping->host->i_size;
-               if (pos + len > isize)
-                       vmtruncate(mapping->host, isize);
-       }
-
-       return ret;
-}
 EXPORT_SYMBOL(cont_write_begin);
 
 int block_prepare_write(struct page *page, unsigned from, unsigned to,
index ffe7c6fdc1ecdb80a58b6a4e203902edee25d6c0..ec6a699a4023da141063176ef11a94e8f8fd4a61 100644 (file)
@@ -159,7 +159,7 @@ static int fat_write_begin(struct file *file, struct address_space *mapping,
        int err;
 
        *pagep = NULL;
-       err = cont_write_begin_newtrunc(file, mapping, pos, len, flags,
+       err = cont_write_begin(file, mapping, pos, len, flags,
                                pagep, fsdata, fat_get_block,
                                &MSDOS_I(mapping->host)->mmu_private);
        if (err < 0)
index 07b2464b5716aaa3d9868be419938dd646cec3c3..8df18e63eb6b1eb2b08b905a8ba055133befd125 100644 (file)
@@ -39,10 +39,19 @@ static int hfs_write_begin(struct file *file, struct address_space *mapping,
                        loff_t pos, unsigned len, unsigned flags,
                        struct page **pagep, void **fsdata)
 {
+       int ret;
+
        *pagep = NULL;
-       return cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+       ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
                                hfs_get_block,
                                &HFS_I(mapping->host)->phys_size);
+       if (unlikely(ret)) {
+               loff_t isize = mapping->host->i_size;
+               if (pos + len > isize)
+                       vmtruncate(mapping->host, isize);
+       }
+
+       return ret;
 }
 
 static sector_t hfs_bmap(struct address_space *mapping, sector_t block)
index 48602177391116c5c55357c5d7077e9fc67a366b..88bf1b562641383e514e41ffa8941b327f913abb 100644 (file)
@@ -31,10 +31,19 @@ static int hfsplus_write_begin(struct file *file, struct address_space *mapping,
                        loff_t pos, unsigned len, unsigned flags,
                        struct page **pagep, void **fsdata)
 {
+       int ret;
+
        *pagep = NULL;
-       return cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+       ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
                                hfsplus_get_block,
                                &HFSPLUS_I(mapping->host).phys_size);
+       if (unlikely(ret)) {
+               loff_t isize = mapping->host->i_size;
+               if (pos + len > isize)
+                       vmtruncate(mapping->host, isize);
+       }
+
+       return ret;
 }
 
 static sector_t hfsplus_bmap(struct address_space *mapping, sector_t block)
index a9ae9bfa752f5a032d411a8def0216027dca54bf..c0340887c7ea619efceba79852159003f3286620 100644 (file)
@@ -97,10 +97,19 @@ static int hpfs_write_begin(struct file *file, struct address_space *mapping,
                        loff_t pos, unsigned len, unsigned flags,
                        struct page **pagep, void **fsdata)
 {
+       int ret;
+
        *pagep = NULL;
-       return cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+       ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
                                hpfs_get_block,
                                &hpfs_i(mapping->host)->mmu_private);
+       if (unlikely(ret)) {
+               loff_t isize = mapping->host->i_size;
+               if (pos + len > isize)
+                       vmtruncate(mapping->host, isize);
+       }
+
+       return ret;
 }
 
 static sector_t _hpfs_bmap(struct address_space *mapping, sector_t block)
index 277575ddc05cbc25035cd335d9acce319c731226..16829722be93658abb8a153bff2422396c02e8b0 100644 (file)
@@ -320,10 +320,19 @@ static int qnx4_write_begin(struct file *file, struct address_space *mapping,
                        struct page **pagep, void **fsdata)
 {
        struct qnx4_inode_info *qnx4_inode = qnx4_i(mapping->host);
+       int ret;
+
        *pagep = NULL;
-       return cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+       ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
                                qnx4_get_block,
                                &qnx4_inode->mmu_private);
+       if (unlikely(ret)) {
+               loff_t isize = mapping->host->i_size;
+               if (pos + len > isize)
+                       vmtruncate(mapping->host, isize);
+       }
+
+       return ret;
 }
 static sector_t qnx4_bmap(struct address_space *mapping, sector_t block)
 {
index cfda5f0b2a4b10d941ab71d97f2358552b57d240..7638647f0424a807b17774594ba70fce5d1825aa 100644 (file)
@@ -217,9 +217,6 @@ int generic_write_end(struct file *, struct address_space *,
                                struct page *, void *);
 void page_zero_new_buffers(struct page *page, unsigned from, unsigned to);
 int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
-int cont_write_begin_newtrunc(struct file *, struct address_space *, loff_t,
-                       unsigned, unsigned, struct page **, void **,
-                       get_block_t *, loff_t *);
 int cont_write_begin(struct file *, struct address_space *, loff_t,
                        unsigned, unsigned, struct page **, void **,
                        get_block_t *, loff_t *);