Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3765016 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro
Browse files

fs: add sync_inode_metadata



Add a new helper to write out the inode using the writeback code,
that is including the correct dirty bit and list manipulation.  A few
of filesystems already opencode this, and a lot of others should be
using it instead of using write_inode_now which also writes out the
data.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 81fca444
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -882,12 +882,8 @@ static struct inode *pohmelfs_alloc_inode(struct super_block *sb)
static int pohmelfs_fsync(struct file *file, int datasync)
{
	struct inode *inode = file->f_mapping->host;
	struct writeback_control wbc = {
		.sync_mode = WB_SYNC_ALL,
		.nr_to_write = 0,	/* sys_fsync did this */
	};

	return sync_inode(inode, &wbc);
	return sync_inode_metadata(inode, 1);
}

ssize_t pohmelfs_write(struct file *file, const char __user *buf,
+1 −5
Original line number Diff line number Diff line
@@ -46,10 +46,6 @@ static int exofs_file_fsync(struct file *filp, int datasync)
{
	int ret;
	struct inode *inode = filp->f_mapping->host;
	struct writeback_control wbc = {
		.sync_mode = WB_SYNC_ALL,
		.nr_to_write = 0, /* metadata-only; caller takes care of data */
	};
	struct super_block *sb;

	if (!(inode->i_state & I_DIRTY))
@@ -57,7 +53,7 @@ static int exofs_file_fsync(struct file *filp, int datasync)
	if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
		return 0;

	ret = sync_inode(inode, &wbc);
	ret = sync_inode_metadata(inode, 1);

	/* This is a good place to write the sb */
	/* TODO: Sechedule an sb-sync on create */
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len)
	if (IS_DIRSYNC(dir)) {
		err = write_one_page(page, 1);
		if (!err)
			err = ext2_sync_inode(dir);
			err = sync_inode_metadata(dir, 1);
	} else {
		unlock_page(page);
	}
+0 −1
Original line number Diff line number Diff line
@@ -120,7 +120,6 @@ extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
extern struct inode *ext2_iget (struct super_block *, unsigned long);
extern int ext2_write_inode (struct inode *, struct writeback_control *);
extern void ext2_evict_inode(struct inode *);
extern int ext2_sync_inode (struct inode *);
extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
extern int ext2_setattr (struct dentry *, struct iattr *);
extern void ext2_set_inode_flags(struct inode *inode);
+1 −10
Original line number Diff line number Diff line
@@ -1203,7 +1203,7 @@ static int ext2_setsize(struct inode *inode, loff_t newsize)
	inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
	if (inode_needs_sync(inode)) {
		sync_mapping_buffers(inode->i_mapping);
		ext2_sync_inode (inode);
		sync_inode_metadata(inode, 1);
	} else {
		mark_inode_dirty(inode);
	}
@@ -1523,15 +1523,6 @@ int ext2_write_inode(struct inode *inode, struct writeback_control *wbc)
	return __ext2_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
}

int ext2_sync_inode(struct inode *inode)
{
	struct writeback_control wbc = {
		.sync_mode = WB_SYNC_ALL,
		.nr_to_write = 0,	/* sys_fsync did this */
	};
	return sync_inode(inode, &wbc);
}

int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
{
	struct inode *inode = dentry->d_inode;
Loading