aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/alloc.h14
-rw-r--r--fs/nilfs2/bmap.h7
-rw-r--r--fs/nilfs2/btnode.h8
-rw-r--r--fs/nilfs2/cpfile.c10
-rw-r--r--fs/nilfs2/dat.c6
-rw-r--r--fs/nilfs2/export.h8
-rw-r--r--fs/nilfs2/ifile.c6
-rw-r--r--fs/nilfs2/inode.c7
-rw-r--r--fs/nilfs2/ioctl.c4
-rw-r--r--fs/nilfs2/mdt.h7
-rw-r--r--fs/nilfs2/nilfs.h17
-rw-r--r--fs/nilfs2/sufile.c8
-rw-r--r--fs/nilfs2/super.c6
-rw-r--r--fs/nilfs2/the_nilfs.c1
-rw-r--r--fs/nilfs2/the_nilfs.h6
15 files changed, 97 insertions, 18 deletions
diff --git a/fs/nilfs2/alloc.h b/fs/nilfs2/alloc.h
index f5fde36b9e28..fb7238100548 100644
--- a/fs/nilfs2/alloc.h
+++ b/fs/nilfs2/alloc.h
@@ -76,15 +76,23 @@ int nilfs_palloc_freev(struct inode *, __u64 *, size_t);
76#define nilfs_clear_bit_atomic ext2_clear_bit_atomic 76#define nilfs_clear_bit_atomic ext2_clear_bit_atomic
77#define nilfs_find_next_zero_bit find_next_zero_bit_le 77#define nilfs_find_next_zero_bit find_next_zero_bit_le
78 78
79/* 79/**
80 * persistent object allocator cache 80 * struct nilfs_bh_assoc - block offset and buffer head association
81 * @blkoff: block offset
82 * @bh: buffer head
81 */ 83 */
82
83struct nilfs_bh_assoc { 84struct nilfs_bh_assoc {
84 unsigned long blkoff; 85 unsigned long blkoff;
85 struct buffer_head *bh; 86 struct buffer_head *bh;
86}; 87};
87 88
89/**
90 * struct nilfs_palloc_cache - persistent object allocator cache
91 * @lock: cache protecting lock
92 * @prev_desc: blockgroup descriptors cache
93 * @prev_bitmap: blockgroup bitmap cache
94 * @prev_entry: translation entries cache
95 */
88struct nilfs_palloc_cache { 96struct nilfs_palloc_cache {
89 spinlock_t lock; 97 spinlock_t lock;
90 struct nilfs_bh_assoc prev_desc; 98 struct nilfs_bh_assoc prev_desc;
diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h
index 40d9f453d31c..b89e68076adc 100644
--- a/fs/nilfs2/bmap.h
+++ b/fs/nilfs2/bmap.h
@@ -135,6 +135,13 @@ struct nilfs_bmap {
135/* state */ 135/* state */
136#define NILFS_BMAP_DIRTY 0x00000001 136#define NILFS_BMAP_DIRTY 0x00000001
137 137
138/**
139 * struct nilfs_bmap_store - shadow copy of bmap state
140 * @data: cached raw block mapping of on-disk inode
141 * @last_allocated_key: cached value of last allocated key for data block
142 * @last_allocated_ptr: cached value of last allocated ptr for data block
143 * @state: cached value of state field of bmap structure
144 */
138struct nilfs_bmap_store { 145struct nilfs_bmap_store {
139 __le64 data[NILFS_BMAP_SIZE / sizeof(__le64)]; 146 __le64 data[NILFS_BMAP_SIZE / sizeof(__le64)];
140 __u64 last_allocated_key; 147 __u64 last_allocated_key;
diff --git a/fs/nilfs2/btnode.h b/fs/nilfs2/btnode.h
index 3a4dd2d8d3fc..d876b565ce64 100644
--- a/fs/nilfs2/btnode.h
+++ b/fs/nilfs2/btnode.h
@@ -29,7 +29,13 @@
29#include <linux/fs.h> 29#include <linux/fs.h>
30#include <linux/backing-dev.h> 30#include <linux/backing-dev.h>
31 31
32 32/**
33 * struct nilfs_btnode_chkey_ctxt - change key context
34 * @oldkey: old key of block's moving content
35 * @newkey: new key for block's content
36 * @bh: buffer head of old buffer
37 * @newbh: buffer head of new buffer
38 */
33struct nilfs_btnode_chkey_ctxt { 39struct nilfs_btnode_chkey_ctxt {
34 __u64 oldkey; 40 __u64 oldkey;
35 __u64 newkey; 41 __u64 newkey;
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
index dab5c4c6dfaf..deaa3d33a0aa 100644
--- a/fs/nilfs2/cpfile.c
+++ b/fs/nilfs2/cpfile.c
@@ -286,7 +286,7 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
286 __u64 cno; 286 __u64 cno;
287 void *kaddr; 287 void *kaddr;
288 unsigned long tnicps; 288 unsigned long tnicps;
289 int ret, ncps, nicps, count, i; 289 int ret, ncps, nicps, nss, count, i;
290 290
291 if (unlikely(start == 0 || start > end)) { 291 if (unlikely(start == 0 || start > end)) {
292 printk(KERN_ERR "%s: invalid range of checkpoint numbers: " 292 printk(KERN_ERR "%s: invalid range of checkpoint numbers: "
@@ -301,6 +301,7 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
301 if (ret < 0) 301 if (ret < 0)
302 goto out_sem; 302 goto out_sem;
303 tnicps = 0; 303 tnicps = 0;
304 nss = 0;
304 305
305 for (cno = start; cno < end; cno += ncps) { 306 for (cno = start; cno < end; cno += ncps) {
306 ncps = nilfs_cpfile_checkpoints_in_block(cpfile, cno, end); 307 ncps = nilfs_cpfile_checkpoints_in_block(cpfile, cno, end);
@@ -318,8 +319,9 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
318 cpfile, cno, cp_bh, kaddr); 319 cpfile, cno, cp_bh, kaddr);
319 nicps = 0; 320 nicps = 0;
320 for (i = 0; i < ncps; i++, cp = (void *)cp + cpsz) { 321 for (i = 0; i < ncps; i++, cp = (void *)cp + cpsz) {
321 WARN_ON(nilfs_checkpoint_snapshot(cp)); 322 if (nilfs_checkpoint_snapshot(cp)) {
322 if (!nilfs_checkpoint_invalid(cp)) { 323 nss++;
324 } else if (!nilfs_checkpoint_invalid(cp)) {
323 nilfs_checkpoint_set_invalid(cp); 325 nilfs_checkpoint_set_invalid(cp);
324 nicps++; 326 nicps++;
325 } 327 }
@@ -364,6 +366,8 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
364 } 366 }
365 367
366 brelse(header_bh); 368 brelse(header_bh);
369 if (nss > 0)
370 ret = -EBUSY;
367 371
368 out_sem: 372 out_sem:
369 up_write(&NILFS_MDT(cpfile)->mi_sem); 373 up_write(&NILFS_MDT(cpfile)->mi_sem);
diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c
index b5c13f3576b9..fa0f80308c2d 100644
--- a/fs/nilfs2/dat.c
+++ b/fs/nilfs2/dat.c
@@ -33,6 +33,12 @@
33#define NILFS_CNO_MIN ((__u64)1) 33#define NILFS_CNO_MIN ((__u64)1)
34#define NILFS_CNO_MAX (~(__u64)0) 34#define NILFS_CNO_MAX (~(__u64)0)
35 35
36/**
37 * struct nilfs_dat_info - on-memory private data of DAT file
38 * @mi: on-memory private data of metadata file
39 * @palloc_cache: persistent object allocator cache of DAT file
40 * @shadow: shadow map of DAT file
41 */
36struct nilfs_dat_info { 42struct nilfs_dat_info {
37 struct nilfs_mdt_info mi; 43 struct nilfs_mdt_info mi;
38 struct nilfs_palloc_cache palloc_cache; 44 struct nilfs_palloc_cache palloc_cache;
diff --git a/fs/nilfs2/export.h b/fs/nilfs2/export.h
index a71cc412b651..19ccbf9522ab 100644
--- a/fs/nilfs2/export.h
+++ b/fs/nilfs2/export.h
@@ -5,6 +5,14 @@
5 5
6extern const struct export_operations nilfs_export_ops; 6extern const struct export_operations nilfs_export_ops;
7 7
8/**
9 * struct nilfs_fid - NILFS file id type
10 * @cno: checkpoint number
11 * @ino: inode number
12 * @gen: file generation (version) for NFS
13 * @parent_gen: parent generation (version) for NFS
14 * @parent_ino: parent inode number
15 */
8struct nilfs_fid { 16struct nilfs_fid {
9 u64 cno; 17 u64 cno;
10 u64 ino; 18 u64 ino;
diff --git a/fs/nilfs2/ifile.c b/fs/nilfs2/ifile.c
index 5a48df79d674..d8e65bde083c 100644
--- a/fs/nilfs2/ifile.c
+++ b/fs/nilfs2/ifile.c
@@ -29,7 +29,11 @@
29#include "alloc.h" 29#include "alloc.h"
30#include "ifile.h" 30#include "ifile.h"
31 31
32 32/**
33 * struct nilfs_ifile_info - on-memory private data of ifile
34 * @mi: on-memory private data of metadata file
35 * @palloc_cache: persistent object allocator cache of ifile
36 */
33struct nilfs_ifile_info { 37struct nilfs_ifile_info {
34 struct nilfs_mdt_info mi; 38 struct nilfs_mdt_info mi;
35 struct nilfs_palloc_cache palloc_cache; 39 struct nilfs_palloc_cache palloc_cache;
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 7cc64465ec26..6e2c3db976b2 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -34,6 +34,13 @@
34#include "cpfile.h" 34#include "cpfile.h"
35#include "ifile.h" 35#include "ifile.h"
36 36
37/**
38 * struct nilfs_iget_args - arguments used during comparison between inodes
39 * @ino: inode number
40 * @cno: checkpoint number
41 * @root: pointer on NILFS root object (mounted checkpoint)
42 * @for_gc: inode for GC flag
43 */
37struct nilfs_iget_args { 44struct nilfs_iget_args {
38 u64 ino; 45 u64 ino;
39 __u64 cno; 46 __u64 cno;
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 08f27968a7a9..fdb180769485 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -182,7 +182,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp,
182 if (copy_from_user(&cpmode, argp, sizeof(cpmode))) 182 if (copy_from_user(&cpmode, argp, sizeof(cpmode)))
183 goto out; 183 goto out;
184 184
185 down_read(&inode->i_sb->s_umount); 185 mutex_lock(&nilfs->ns_snapshot_mount_mutex);
186 186
187 nilfs_transaction_begin(inode->i_sb, &ti, 0); 187 nilfs_transaction_begin(inode->i_sb, &ti, 0);
188 ret = nilfs_cpfile_change_cpmode( 188 ret = nilfs_cpfile_change_cpmode(
@@ -192,7 +192,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp,
192 else 192 else
193 nilfs_transaction_commit(inode->i_sb); /* never fails */ 193 nilfs_transaction_commit(inode->i_sb); /* never fails */
194 194
195 up_read(&inode->i_sb->s_umount); 195 mutex_unlock(&nilfs->ns_snapshot_mount_mutex);
196out: 196out:
197 mnt_drop_write_file(filp); 197 mnt_drop_write_file(filp);
198 return ret; 198 return ret;
diff --git a/fs/nilfs2/mdt.h b/fs/nilfs2/mdt.h
index ab20a4baa50f..ab172e8549c5 100644
--- a/fs/nilfs2/mdt.h
+++ b/fs/nilfs2/mdt.h
@@ -28,6 +28,13 @@
28#include "nilfs.h" 28#include "nilfs.h"
29#include "page.h" 29#include "page.h"
30 30
31/**
32 * struct nilfs_shadow_map - shadow mapping of meta data file
33 * @bmap_store: shadow copy of bmap state
34 * @frozen_data: shadowed dirty data pages
35 * @frozen_btnodes: shadowed dirty b-tree nodes' pages
36 * @frozen_buffers: list of frozen buffers
37 */
31struct nilfs_shadow_map { 38struct nilfs_shadow_map {
32 struct nilfs_bmap_store bmap_store; 39 struct nilfs_bmap_store bmap_store;
33 struct address_space frozen_data; 40 struct address_space frozen_data;
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 250add84da76..74cece80e9a3 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -32,8 +32,21 @@
32#include "the_nilfs.h" 32#include "the_nilfs.h"
33#include "bmap.h" 33#include "bmap.h"
34 34
35/* 35/**
36 * nilfs inode data in memory 36 * struct nilfs_inode_info - nilfs inode data in memory
37 * @i_flags: inode flags
38 * @i_state: dynamic state flags
39 * @i_bmap: pointer on i_bmap_data
40 * @i_bmap_data: raw block mapping
41 * @i_xattr: <TODO>
42 * @i_dir_start_lookup: page index of last successful search
43 * @i_cno: checkpoint number for GC inode
44 * @i_btnode_cache: cached pages of b-tree nodes
45 * @i_dirty: list for connecting dirty files
46 * @xattr_sem: semaphore for extended attributes processing
47 * @i_bh: buffer contains disk inode
48 * @i_root: root object of the current filesystem tree
49 * @vfs_inode: VFS inode object
37 */ 50 */
38struct nilfs_inode_info { 51struct nilfs_inode_info {
39 __u32 i_flags; 52 __u32 i_flags;
diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c
index c5b7653a4391..3127e9f438a7 100644
--- a/fs/nilfs2/sufile.c
+++ b/fs/nilfs2/sufile.c
@@ -30,7 +30,13 @@
30#include "mdt.h" 30#include "mdt.h"
31#include "sufile.h" 31#include "sufile.h"
32 32
33 33/**
34 * struct nilfs_sufile_info - on-memory private data of sufile
35 * @mi: on-memory private data of metadata file
36 * @ncleansegs: number of clean segments
37 * @allocmin: lower limit of allocatable segment range
38 * @allocmax: upper limit of allocatable segment range
39 */
34struct nilfs_sufile_info { 40struct nilfs_sufile_info {
35 struct nilfs_mdt_info mi; 41 struct nilfs_mdt_info mi;
36 unsigned long ncleansegs;/* number of clean segments */ 42 unsigned long ncleansegs;/* number of clean segments */
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index d57c42f974ea..6522cac6057c 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -677,7 +677,6 @@ static const struct super_operations nilfs_sops = {
677 .destroy_inode = nilfs_destroy_inode, 677 .destroy_inode = nilfs_destroy_inode,
678 .dirty_inode = nilfs_dirty_inode, 678 .dirty_inode = nilfs_dirty_inode,
679 /* .write_inode = nilfs_write_inode, */ 679 /* .write_inode = nilfs_write_inode, */
680 /* .put_inode = nilfs_put_inode, */
681 /* .drop_inode = nilfs_drop_inode, */ 680 /* .drop_inode = nilfs_drop_inode, */
682 .evict_inode = nilfs_evict_inode, 681 .evict_inode = nilfs_evict_inode,
683 .put_super = nilfs_put_super, 682 .put_super = nilfs_put_super,
@@ -685,8 +684,6 @@ static const struct super_operations nilfs_sops = {
685 .sync_fs = nilfs_sync_fs, 684 .sync_fs = nilfs_sync_fs,
686 .freeze_fs = nilfs_freeze, 685 .freeze_fs = nilfs_freeze,
687 .unfreeze_fs = nilfs_unfreeze, 686 .unfreeze_fs = nilfs_unfreeze,
688 /* .write_super_lockfs */
689 /* .unlockfs */
690 .statfs = nilfs_statfs, 687 .statfs = nilfs_statfs,
691 .remount_fs = nilfs_remount, 688 .remount_fs = nilfs_remount,
692 /* .umount_begin */ 689 /* .umount_begin */
@@ -948,6 +945,8 @@ static int nilfs_attach_snapshot(struct super_block *s, __u64 cno,
948 struct nilfs_root *root; 945 struct nilfs_root *root;
949 int ret; 946 int ret;
950 947
948 mutex_lock(&nilfs->ns_snapshot_mount_mutex);
949
951 down_read(&nilfs->ns_segctor_sem); 950 down_read(&nilfs->ns_segctor_sem);
952 ret = nilfs_cpfile_is_snapshot(nilfs->ns_cpfile, cno); 951 ret = nilfs_cpfile_is_snapshot(nilfs->ns_cpfile, cno);
953 up_read(&nilfs->ns_segctor_sem); 952 up_read(&nilfs->ns_segctor_sem);
@@ -972,6 +971,7 @@ static int nilfs_attach_snapshot(struct super_block *s, __u64 cno,
972 ret = nilfs_get_root_dentry(s, root, root_dentry); 971 ret = nilfs_get_root_dentry(s, root, root_dentry);
973 nilfs_put_root(root); 972 nilfs_put_root(root);
974 out: 973 out:
974 mutex_unlock(&nilfs->ns_snapshot_mount_mutex);
975 return ret; 975 return ret;
976} 976}
977 977
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 501b7f8b739f..41e6a04a561f 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -76,6 +76,7 @@ struct the_nilfs *alloc_nilfs(struct block_device *bdev)
76 nilfs->ns_bdev = bdev; 76 nilfs->ns_bdev = bdev;
77 atomic_set(&nilfs->ns_ndirtyblks, 0); 77 atomic_set(&nilfs->ns_ndirtyblks, 0);
78 init_rwsem(&nilfs->ns_sem); 78 init_rwsem(&nilfs->ns_sem);
79 mutex_init(&nilfs->ns_snapshot_mount_mutex);
79 INIT_LIST_HEAD(&nilfs->ns_dirty_files); 80 INIT_LIST_HEAD(&nilfs->ns_dirty_files);
80 INIT_LIST_HEAD(&nilfs->ns_gc_inodes); 81 INIT_LIST_HEAD(&nilfs->ns_gc_inodes);
81 spin_lock_init(&nilfs->ns_inode_lock); 82 spin_lock_init(&nilfs->ns_inode_lock);
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h
index 9992b11312ff..6eee4177807b 100644
--- a/fs/nilfs2/the_nilfs.h
+++ b/fs/nilfs2/the_nilfs.h
@@ -47,11 +47,13 @@ enum {
47 * @ns_flags: flags 47 * @ns_flags: flags
48 * @ns_bdev: block device 48 * @ns_bdev: block device
49 * @ns_sem: semaphore for shared states 49 * @ns_sem: semaphore for shared states
50 * @ns_snapshot_mount_mutex: mutex to protect snapshot mounts
50 * @ns_sbh: buffer heads of on-disk super blocks 51 * @ns_sbh: buffer heads of on-disk super blocks
51 * @ns_sbp: pointers to super block data 52 * @ns_sbp: pointers to super block data
52 * @ns_sbwtime: previous write time of super block 53 * @ns_sbwtime: previous write time of super block
53 * @ns_sbwcount: write count of super block 54 * @ns_sbwcount: write count of super block
54 * @ns_sbsize: size of valid data in super block 55 * @ns_sbsize: size of valid data in super block
56 * @ns_mount_state: file system state
55 * @ns_seg_seq: segment sequence counter 57 * @ns_seg_seq: segment sequence counter
56 * @ns_segnum: index number of the latest full segment. 58 * @ns_segnum: index number of the latest full segment.
57 * @ns_nextnum: index number of the full segment index to be used next 59 * @ns_nextnum: index number of the full segment index to be used next
@@ -99,6 +101,7 @@ struct the_nilfs {
99 101
100 struct block_device *ns_bdev; 102 struct block_device *ns_bdev;
101 struct rw_semaphore ns_sem; 103 struct rw_semaphore ns_sem;
104 struct mutex ns_snapshot_mount_mutex;
102 105
103 /* 106 /*
104 * used for 107 * used for
@@ -229,9 +232,8 @@ THE_NILFS_FNS(SB_DIRTY, sb_dirty)
229 * @count: refcount of this structure 232 * @count: refcount of this structure
230 * @nilfs: nilfs object 233 * @nilfs: nilfs object
231 * @ifile: inode file 234 * @ifile: inode file
232 * @root: root inode
233 * @inodes_count: number of inodes 235 * @inodes_count: number of inodes
234 * @blocks_count: number of blocks (Reserved) 236 * @blocks_count: number of blocks
235 */ 237 */
236struct nilfs_root { 238struct nilfs_root {
237 __u64 cno; 239 __u64 cno;