filesystem freeze: implement generic freeze feature
Subsystems (2)
PATCH 6/8 filesystem freeze: implement generic freeze feature
From: Takashi Sato <[email protected]>
The ioctls for the generic freeze feature are below.
o Freeze the filesystem
int ioctl(int fd, int FIFREEZE, arg)
fd: The file descriptor of the mountpoint
FIFREEZE: request code for the freeze
arg: Ignored
Return value: 0 if the operation succeeds. Otherwise, -1
o Unfreeze the filesystem
int ioctl(int fd, int FITHAW, arg)
fd: The file descriptor of the mountpoint
FITHAW: request code for unfreeze
arg: Ignored
Return value: 0 if the operation succeeds. Otherwise, -1 Error number: If the filesystem has already been unfrozen,
errno is set to EINVAL.
---
fs/block_dev.c | 2 fs/buffer.c | 74 +++++++++++++++++++++++++++++----- fs/ioctl.c | 46 +++++++++++++++++++++ include/linux/buffer_head.h | 11 ++++- include/linux/fs.h | 7 +++ 5 files changed, 130 insertions(+), 10 deletions(-)
fs/block_dev.c renamed from fs/block_dev.c~filesystem-freeze-implement-generic-freeze-feature +2 -0
@@ -285,6 +285,8 @@ static void init_once(void *foo)INIT_LIST_HEAD (&bdev->bd_holder_list);#endif inode_init_once (&ei->vfs_inode); +/* Initialize mutex for freeze. */ +mutex_init (&bdev->bd_fsfreeze_mutex); }static inline void __bd_forget (struct inode *inode)
fs/buffer.c renamed from fs/buffer.c~filesystem-freeze-implement-generic-freeze-feature +65 -9
106 lines not on this page · raw message
fs/ioctl.c renamed from fs/ioctl.c~filesystem-freeze-implement-generic-freeze-feature +46 -0
58 lines not on this page · raw message
include/linux/buffer_head.h renamed from include/linux/buffer_head.h~filesystem-freeze-implement-generic-freeze-feature +10 -1
@@ -171,7 +171,7 @@ void __wait_on_buffer(struct buffer_headwait_queue_head_t *bh_waitq_head (struct buffer_head *bh);int fsync_bdev (struct block_device *);struct super_block *freeze_bdev (struct block_device *); -void thaw_bdev (struct block_device *,struct super_block *); +int thaw_bdev (struct block_device *,struct super_block *);int fsync_super (struct super_block *);int fsync_no_super (struct block_device *); struct buffer_head *__find_get_block(struct block_device *bdev, sector_t block,
@@ -346,6 +346,15 @@ static inline int remove_inode_buffers(sstatic inline int sync_mapping_buffers (struct address_space *mapping) {return 0 ; }static inline void invalidate_bdev (struct block_device *bdev) {} +static inline struct super_block *freeze_bdev (struct block_device *sb) +{ +return NULL ; +} + +static inline int thaw_bdev (struct block_device *bdev,struct super_block *sb) +{ +return 0 ; +}#endif /* CONFIG_BLOCK */ #endif /* _LINUX_BUFFER_HEAD_H */
include/linux/fs.h renamed from include/linux/fs.h~filesystem-freeze-implement-generic-freeze-feature +7 -0
@@ -234,6 +234,8 @@ struct inodes_stat_t {#define BMAP_IOCTL 1/* obsolete - kept for compatibility */ #define FIBMAP _IO(0x00,1)/* bmap access */ #define FIGETBSZ _IO(0x00,2)/* get the block size used for bmap */ +#define FIFREEZE _IOWR('X', 119, int)/* Freeze */ +#define FITHAW _IOWR('X', 120, int)/* Thaw */ #define FS_IOC_GETFLAGS _IOR('f', 1, long)#define FS_IOC_SETFLAGS _IOW('f', 2, long)
@@ -591,6 +593,11 @@ struct block_device {* care to not mess up bd_private for that case. */ unsigned long bd_private; + +/* The counter of freeze processes */ +int bd_fsfreeze_count; +/* Mutex for freeze */ +struct mutex bd_fsfreeze_mutex; };/*
_