Unverified Commit 76147526 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Christian Brauner
Browse files

fs: refactor ->update_time handling



Pass the type of update (atime vs c/mtime plus version) as an enum
instead of a set of flags that caused all kinds of confusion.
Because inode_update_timestamps now can't return a modified version
of those flags, return the I_DIRTY_* flags needed to persist the
update, which is what the main caller in generic_update_time wants
anyway, and which is suitable for the other callers that only want
to know if an update happened.

The whole update_time path keeps the flags argument, which will be used
to support non-blocking updates soon even if it is unused, and (the
slightly renamed) inode_update_time also gains the possibility to return
a negative errno to support this.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260108141934.2052404-6-hch@lst.de


Reviewed-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 1cbc8228
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -80,7 +80,8 @@ prototypes::
	int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
	ssize_t (*listxattr) (struct dentry *, char *, size_t);
	int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len);
	void (*update_time)(struct inode *, struct timespec *, int);
	void (*update_time)(struct inode *inode, enum fs_update_time type,
			    int flags);
	int (*atomic_open)(struct inode *, struct dentry *,
				struct file *, unsigned open_flag,
				umode_t create_mode);
+2 −1
Original line number Diff line number Diff line
@@ -485,7 +485,8 @@ As of kernel 2.6.22, the following members are defined:
		int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
		int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
		ssize_t (*listxattr) (struct dentry *, char *, size_t);
		void (*update_time)(struct inode *, struct timespec *, int);
		void (*update_time)(struct inode *inode, enum fs_update_time type,
				    int flags);
		int (*atomic_open)(struct inode *, struct dentry *, struct file *,
				   unsigned open_flag, umode_t create_mode);
		int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
+2 −1
Original line number Diff line number Diff line
@@ -133,7 +133,8 @@ static int bad_inode_fiemap(struct inode *inode,
	return -EIO;
}

static int bad_inode_update_time(struct inode *inode, int flags)
static int bad_inode_update_time(struct inode *inode, enum fs_update_time type,
				 unsigned int flags)
{
	return -EIO;
}
+7 −4
Original line number Diff line number Diff line
@@ -6345,16 +6345,19 @@ static int btrfs_dirty_inode(struct btrfs_inode *inode)
 * We need our own ->update_time so that we can return error on ENOSPC for
 * updating the inode in the case of file write and mmap writes.
 */
static int btrfs_update_time(struct inode *inode, int flags)
static int btrfs_update_time(struct inode *inode, enum fs_update_time type,
		unsigned int flags)
{
	struct btrfs_root *root = BTRFS_I(inode)->root;
	bool dirty;
	int dirty;

	if (btrfs_root_readonly(root))
		return -EROFS;

	dirty = inode_update_timestamps(inode, flags);
	return dirty ? btrfs_dirty_inode(BTRFS_I(inode)) : 0;
	dirty = inode_update_time(inode, type, flags);
	if (dirty <= 0)
		return dirty;
	return btrfs_dirty_inode(BTRFS_I(inode));
}

/*
+2 −1
Original line number Diff line number Diff line
@@ -472,7 +472,8 @@ extern struct timespec64 fat_truncate_atime(const struct msdos_sb_info *sbi,
#define FAT_UPDATE_CMTIME	(1u << 1)
void fat_truncate_time(struct inode *inode, struct timespec64 *now,
		unsigned int flags);
extern int fat_update_time(struct inode *inode, int flags);
int fat_update_time(struct inode *inode, enum fs_update_time type,
		unsigned int flags);
extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs);

int fat_cache_init(void);
Loading