mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 06:01:23 +00:00
NFS: Clean up NFS writeback flush code
The only user of nfs_sync_mapping_range() is nfs_getattr(), which uses it to flush out the entire inode without sending a commit. We therefore replace nfs_sync_mapping_range with a more appropriate helper. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
90e9a3f9b0
commit
ed90ef51a3
3 changed files with 16 additions and 29 deletions
|
@ -431,7 +431,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
|
||||||
|
|
||||||
/* Flush out writes to the server in order to update c/mtime */
|
/* Flush out writes to the server in order to update c/mtime */
|
||||||
if (S_ISREG(inode->i_mode))
|
if (S_ISREG(inode->i_mode))
|
||||||
nfs_sync_mapping_range(inode->i_mapping, 0, 0, FLUSH_NOCOMMIT);
|
nfs_wb_nocommit(inode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We may force a getattr if the user cares about atime.
|
* We may force a getattr if the user cares about atime.
|
||||||
|
|
|
@ -1325,12 +1325,8 @@ long nfs_sync_mapping_wait(struct address_space *mapping, struct writeback_contr
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static int nfs_write_mapping(struct address_space *mapping, int how)
|
||||||
* flush the inode to disk.
|
|
||||||
*/
|
|
||||||
int nfs_wb_all(struct inode *inode)
|
|
||||||
{
|
{
|
||||||
struct address_space *mapping = inode->i_mapping;
|
|
||||||
struct writeback_control wbc = {
|
struct writeback_control wbc = {
|
||||||
.bdi = mapping->backing_dev_info,
|
.bdi = mapping->backing_dev_info,
|
||||||
.sync_mode = WB_SYNC_ALL,
|
.sync_mode = WB_SYNC_ALL,
|
||||||
|
@ -1343,35 +1339,26 @@ int nfs_wb_all(struct inode *inode)
|
||||||
ret = nfs_writepages(mapping, &wbc);
|
ret = nfs_writepages(mapping, &wbc);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
ret = nfs_sync_mapping_wait(mapping, &wbc, 0);
|
ret = nfs_sync_mapping_wait(mapping, &wbc, how);
|
||||||
if (ret >= 0)
|
if (ret < 0)
|
||||||
return 0;
|
goto out;
|
||||||
|
return 0;
|
||||||
out:
|
out:
|
||||||
__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
|
__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nfs_sync_mapping_range(struct address_space *mapping, loff_t range_start, loff_t range_end, int how)
|
/*
|
||||||
|
* flush the inode to disk.
|
||||||
|
*/
|
||||||
|
int nfs_wb_all(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct writeback_control wbc = {
|
return nfs_write_mapping(inode->i_mapping, 0);
|
||||||
.bdi = mapping->backing_dev_info,
|
}
|
||||||
.sync_mode = WB_SYNC_ALL,
|
|
||||||
.nr_to_write = LONG_MAX,
|
|
||||||
.range_start = range_start,
|
|
||||||
.range_end = range_end,
|
|
||||||
.for_writepages = 1,
|
|
||||||
};
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = nfs_writepages(mapping, &wbc);
|
int nfs_wb_nocommit(struct inode *inode)
|
||||||
if (ret < 0)
|
{
|
||||||
goto out;
|
return nfs_write_mapping(inode->i_mapping, FLUSH_NOCOMMIT);
|
||||||
ret = nfs_sync_mapping_wait(mapping, &wbc, how);
|
|
||||||
if (ret >= 0)
|
|
||||||
return 0;
|
|
||||||
out:
|
|
||||||
__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int nfs_wb_page_cancel(struct inode *inode, struct page *page)
|
int nfs_wb_page_cancel(struct inode *inode, struct page *page)
|
||||||
|
|
|
@ -426,8 +426,8 @@ extern void nfs_writedata_release(void *);
|
||||||
* return value!)
|
* return value!)
|
||||||
*/
|
*/
|
||||||
extern long nfs_sync_mapping_wait(struct address_space *, struct writeback_control *, int);
|
extern long nfs_sync_mapping_wait(struct address_space *, struct writeback_control *, int);
|
||||||
extern int nfs_sync_mapping_range(struct address_space *, loff_t, loff_t, int);
|
|
||||||
extern int nfs_wb_all(struct inode *inode);
|
extern int nfs_wb_all(struct inode *inode);
|
||||||
|
extern int nfs_wb_nocommit(struct inode *inode);
|
||||||
extern int nfs_wb_page(struct inode *inode, struct page* page);
|
extern int nfs_wb_page(struct inode *inode, struct page* page);
|
||||||
extern int nfs_wb_page_priority(struct inode *inode, struct page* page, int how);
|
extern int nfs_wb_page_priority(struct inode *inode, struct page* page, int how);
|
||||||
extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
|
extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue