From: Christoph Hellwig <hch@lst.de>
To: viro@zeniv.linux.org.uk, npiggin@suse.de
Cc: jack@suse.cz, linux-fsdevel@vger.kernel.org
Subject: [PATCH 3/6] get rid of cont_write_begin_newtrunc
Date: Sun, 30 May 2010 22:50:00 +0200 [thread overview]
Message-ID: <20100530205000.GD21002@lst.de> (raw)
In-Reply-To: <20100530204932.GA21002@lst.de>
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>
Index: linux-2.6/fs/adfs/inode.c
===================================================================
--- linux-2.6.orig/fs/adfs/inode.c 2010-05-30 22:28:16.408003507 +0200
+++ linux-2.6/fs/adfs/inode.c 2010-05-30 22:32:22.749253611 +0200
@@ -50,10 +50,19 @@ static int adfs_write_begin(struct file
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: linux-2.6/fs/affs/file.c
===================================================================
--- linux-2.6.orig/fs/affs/file.c 2010-05-30 22:28:16.417004066 +0200
+++ linux-2.6/fs/affs/file.c 2010-05-30 22:32:22.749253611 +0200
@@ -406,10 +406,19 @@ static int affs_write_begin(struct file
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: linux-2.6/fs/buffer.c
===================================================================
--- linux-2.6.orig/fs/buffer.c 2010-05-30 22:30:49.341024320 +0200
+++ linux-2.6/fs/buffer.c 2010-05-30 22:32:22.754253961 +0200
@@ -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 fil
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: linux-2.6/fs/fat/inode.c
===================================================================
--- linux-2.6.orig/fs/fat/inode.c 2010-05-30 22:28:18.685253821 +0200
+++ linux-2.6/fs/fat/inode.c 2010-05-30 22:32:22.762255008 +0200
@@ -159,7 +159,7 @@ static int fat_write_begin(struct file *
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: linux-2.6/fs/hfs/inode.c
===================================================================
--- linux-2.6.orig/fs/hfs/inode.c 2010-05-30 22:28:18.686254310 +0200
+++ linux-2.6/fs/hfs/inode.c 2010-05-30 22:32:22.763254240 +0200
@@ -39,10 +39,19 @@ static int hfs_write_begin(struct file *
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: linux-2.6/fs/hfsplus/inode.c
===================================================================
--- linux-2.6.orig/fs/hfsplus/inode.c 2010-05-30 22:28:18.691253611 +0200
+++ linux-2.6/fs/hfsplus/inode.c 2010-05-30 22:32:22.768253611 +0200
@@ -31,10 +31,19 @@ static int hfsplus_write_begin(struct fi
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: linux-2.6/fs/hpfs/file.c
===================================================================
--- linux-2.6.orig/fs/hpfs/file.c 2010-05-30 22:28:16.461004695 +0200
+++ linux-2.6/fs/hpfs/file.c 2010-05-30 22:32:22.773253611 +0200
@@ -97,10 +97,19 @@ static int hpfs_write_begin(struct file
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: linux-2.6/fs/qnx4/inode.c
===================================================================
--- linux-2.6.orig/fs/qnx4/inode.c 2010-05-30 22:28:16.468003507 +0200
+++ linux-2.6/fs/qnx4/inode.c 2010-05-30 22:32:22.778253891 +0200
@@ -320,10 +320,19 @@ static int qnx4_write_begin(struct file
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: linux-2.6/include/linux/buffer_head.h
===================================================================
--- linux-2.6.orig/include/linux/buffer_head.h 2010-05-30 22:30:49.611005673 +0200
+++ linux-2.6/include/linux/buffer_head.h 2010-05-30 22:32:22.783254030 +0200
@@ -217,9 +217,6 @@ int generic_write_end(struct file *, str
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 *);
next prev parent reply other threads:[~2010-05-30 20:50 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-30 20:49 [PATCH 0/6] first step toward the new truncate sequence Christoph Hellwig
2010-05-30 20:49 ` [PATCH 1/6] sort out blockdev_direct_IO variants Christoph Hellwig
2010-06-01 23:00 ` Jan Kara
2010-06-01 23:12 ` Christoph Hellwig
2010-06-01 23:16 ` Jan Kara
2010-05-30 20:49 ` [PATCH 2/6] get rid of nobh_write_begin_newtrunc Christoph Hellwig
2010-05-30 20:50 ` Christoph Hellwig [this message]
2010-05-30 20:50 ` [PATCH 4/6] clean up write_begin usage for directories in pagecache Christoph Hellwig
2010-05-30 20:50 ` [PATCH 5/6] introduce __block_write_begin Christoph Hellwig
2010-05-31 8:10 ` Christoph Hellwig
2010-06-01 23:39 ` Jan Kara
2010-06-02 7:25 ` Christoph Hellwig
2010-06-02 9:47 ` Jan Kara
2010-05-30 20:50 ` [PATCH 6/6] get rid of block_write_begin_newtrunc Christoph Hellwig
2010-05-31 7:13 ` [PATCH 0/6] first step toward the new truncate sequence Nick Piggin
2010-05-31 7:38 ` Christoph Hellwig
2010-05-31 7:45 ` Nick Piggin
2010-05-31 9:50 ` Boaz Harrosh
2010-05-31 10:17 ` Boaz Harrosh
2010-05-31 13:15 ` Nick Piggin
2010-05-31 13:18 ` Christoph Hellwig
2010-05-31 13:21 ` Boaz Harrosh
2010-06-01 10:07 ` 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=20100530205000.GD21002@lst.de \
--to=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=npiggin@suse.de \
--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.