fs: fold __generic_write_end back into generic_write_end
This effectively reverts a6d639da63
("fs: factor out a
__generic_write_end helper") as we now open code what is left of that
helper in iomap.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
parent
8d3e72a180
commit
8af54f291e
62
fs/buffer.c
62
fs/buffer.c
|
@ -2086,38 +2086,6 @@ int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(block_write_begin);
|
EXPORT_SYMBOL(block_write_begin);
|
||||||
|
|
||||||
void __generic_write_end(struct inode *inode, loff_t pos, unsigned copied,
|
|
||||||
struct page *page)
|
|
||||||
{
|
|
||||||
loff_t old_size = inode->i_size;
|
|
||||||
bool i_size_changed = false;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* No need to use i_size_read() here, the i_size cannot change under us
|
|
||||||
* because we hold i_rwsem.
|
|
||||||
*
|
|
||||||
* But it's important to update i_size while still holding page lock:
|
|
||||||
* page writeout could otherwise come in and zero beyond i_size.
|
|
||||||
*/
|
|
||||||
if (pos + copied > inode->i_size) {
|
|
||||||
i_size_write(inode, pos + copied);
|
|
||||||
i_size_changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
unlock_page(page);
|
|
||||||
|
|
||||||
if (old_size < pos)
|
|
||||||
pagecache_isize_extended(inode, old_size, pos);
|
|
||||||
/*
|
|
||||||
* Don't mark the inode dirty under page lock. First, it unnecessarily
|
|
||||||
* makes the holding time of page lock longer. Second, it forces lock
|
|
||||||
* ordering of page lock and transaction start for journaling
|
|
||||||
* filesystems.
|
|
||||||
*/
|
|
||||||
if (i_size_changed)
|
|
||||||
mark_inode_dirty(inode);
|
|
||||||
}
|
|
||||||
|
|
||||||
int block_write_end(struct file *file, struct address_space *mapping,
|
int block_write_end(struct file *file, struct address_space *mapping,
|
||||||
loff_t pos, unsigned len, unsigned copied,
|
loff_t pos, unsigned len, unsigned copied,
|
||||||
struct page *page, void *fsdata)
|
struct page *page, void *fsdata)
|
||||||
|
@ -2158,9 +2126,37 @@ int generic_write_end(struct file *file, struct address_space *mapping,
|
||||||
loff_t pos, unsigned len, unsigned copied,
|
loff_t pos, unsigned len, unsigned copied,
|
||||||
struct page *page, void *fsdata)
|
struct page *page, void *fsdata)
|
||||||
{
|
{
|
||||||
|
struct inode *inode = mapping->host;
|
||||||
|
loff_t old_size = inode->i_size;
|
||||||
|
bool i_size_changed = false;
|
||||||
|
|
||||||
copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
|
copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
|
||||||
__generic_write_end(mapping->host, pos, copied, page);
|
|
||||||
|
/*
|
||||||
|
* No need to use i_size_read() here, the i_size cannot change under us
|
||||||
|
* because we hold i_rwsem.
|
||||||
|
*
|
||||||
|
* But it's important to update i_size while still holding page lock:
|
||||||
|
* page writeout could otherwise come in and zero beyond i_size.
|
||||||
|
*/
|
||||||
|
if (pos + copied > inode->i_size) {
|
||||||
|
i_size_write(inode, pos + copied);
|
||||||
|
i_size_changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
unlock_page(page);
|
||||||
put_page(page);
|
put_page(page);
|
||||||
|
|
||||||
|
if (old_size < pos)
|
||||||
|
pagecache_isize_extended(inode, old_size, pos);
|
||||||
|
/*
|
||||||
|
* Don't mark the inode dirty under page lock. First, it unnecessarily
|
||||||
|
* makes the holding time of page lock longer. Second, it forces lock
|
||||||
|
* ordering of page lock and transaction start for journaling
|
||||||
|
* filesystems.
|
||||||
|
*/
|
||||||
|
if (i_size_changed)
|
||||||
|
mark_inode_dirty(inode);
|
||||||
return copied;
|
return copied;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(generic_write_end);
|
EXPORT_SYMBOL(generic_write_end);
|
||||||
|
|
|
@ -40,8 +40,6 @@ static inline int __sync_blockdev(struct block_device *bdev, int wait)
|
||||||
extern void guard_bio_eod(int rw, struct bio *bio);
|
extern void guard_bio_eod(int rw, struct bio *bio);
|
||||||
extern int __block_write_begin_int(struct page *page, loff_t pos, unsigned len,
|
extern int __block_write_begin_int(struct page *page, loff_t pos, unsigned len,
|
||||||
get_block_t *get_block, struct iomap *iomap);
|
get_block_t *get_block, struct iomap *iomap);
|
||||||
void __generic_write_end(struct inode *inode, loff_t pos, unsigned copied,
|
|
||||||
struct page *page);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* char_dev.c
|
* char_dev.c
|
||||||
|
|
Loading…
Reference in New Issue