aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2016-08-02 17:05:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-02 19:35:17 -0400
commit6625689e159fa1d43572ee113713ab23bec03131 (patch)
tree344f75d3ff037dd65e07eb96a47214ed3cc867f1
parenta66dfb0a91c211c77b5d4e503d3e760e2e566189 (diff)
nilfs2: embed a back pointer to super block instance in nilfs object
Insert a back pointer to super block instance in nilfs object so that functions of nilfs2 easily refer to the super block instance. This simplifies replacement of printk() in the successive change. Link: http://lkml.kernel.org/r/1464875891-5443-4-git-send-email-konishi.ryusuke@lab.ntt.co.jp Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/nilfs2/super.c2
-rw-r--r--fs/nilfs2/the_nilfs.c7
-rw-r--r--fs/nilfs2/the_nilfs.h4
3 files changed, 8 insertions, 5 deletions
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 86e3c00994e2..2d4d0bec711e 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -1076,7 +1076,7 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent)
1076 __u64 cno; 1076 __u64 cno;
1077 int err; 1077 int err;
1078 1078
1079 nilfs = alloc_nilfs(sb->s_bdev); 1079 nilfs = alloc_nilfs(sb);
1080 if (!nilfs) 1080 if (!nilfs)
1081 return -ENOMEM; 1081 return -ENOMEM;
1082 1082
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index e9fd241b9a0a..702115164cf3 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -56,12 +56,12 @@ void nilfs_set_last_segment(struct the_nilfs *nilfs,
56 56
57/** 57/**
58 * alloc_nilfs - allocate a nilfs object 58 * alloc_nilfs - allocate a nilfs object
59 * @bdev: block device to which the_nilfs is related 59 * @sb: super block instance
60 * 60 *
61 * Return Value: On success, pointer to the_nilfs is returned. 61 * Return Value: On success, pointer to the_nilfs is returned.
62 * On error, NULL is returned. 62 * On error, NULL is returned.
63 */ 63 */
64struct the_nilfs *alloc_nilfs(struct block_device *bdev) 64struct the_nilfs *alloc_nilfs(struct super_block *sb)
65{ 65{
66 struct the_nilfs *nilfs; 66 struct the_nilfs *nilfs;
67 67
@@ -69,7 +69,8 @@ struct the_nilfs *alloc_nilfs(struct block_device *bdev)
69 if (!nilfs) 69 if (!nilfs)
70 return NULL; 70 return NULL;
71 71
72 nilfs->ns_bdev = bdev; 72 nilfs->ns_sb = sb;
73 nilfs->ns_bdev = sb->s_bdev;
73 atomic_set(&nilfs->ns_ndirtyblks, 0); 74 atomic_set(&nilfs->ns_ndirtyblks, 0);
74 init_rwsem(&nilfs->ns_sem); 75 init_rwsem(&nilfs->ns_sem);
75 mutex_init(&nilfs->ns_snapshot_mount_mutex); 76 mutex_init(&nilfs->ns_snapshot_mount_mutex);
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h
index 79369fd6b13b..79d1421896d0 100644
--- a/fs/nilfs2/the_nilfs.h
+++ b/fs/nilfs2/the_nilfs.h
@@ -43,6 +43,7 @@ enum {
43 * struct the_nilfs - struct to supervise multiple nilfs mount points 43 * struct the_nilfs - struct to supervise multiple nilfs mount points
44 * @ns_flags: flags 44 * @ns_flags: flags
45 * @ns_flushed_device: flag indicating if all volatile data was flushed 45 * @ns_flushed_device: flag indicating if all volatile data was flushed
46 * @ns_sb: back pointer to super block instance
46 * @ns_bdev: block device 47 * @ns_bdev: block device
47 * @ns_sem: semaphore for shared states 48 * @ns_sem: semaphore for shared states
48 * @ns_snapshot_mount_mutex: mutex to protect snapshot mounts 49 * @ns_snapshot_mount_mutex: mutex to protect snapshot mounts
@@ -102,6 +103,7 @@ struct the_nilfs {
102 unsigned long ns_flags; 103 unsigned long ns_flags;
103 int ns_flushed_device; 104 int ns_flushed_device;
104 105
106 struct super_block *ns_sb;
105 struct block_device *ns_bdev; 107 struct block_device *ns_bdev;
106 struct rw_semaphore ns_sem; 108 struct rw_semaphore ns_sem;
107 struct mutex ns_snapshot_mount_mutex; 109 struct mutex ns_snapshot_mount_mutex;
@@ -281,7 +283,7 @@ static inline int nilfs_sb_will_flip(struct the_nilfs *nilfs)
281} 283}
282 284
283void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64); 285void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64);
284struct the_nilfs *alloc_nilfs(struct block_device *bdev); 286struct the_nilfs *alloc_nilfs(struct super_block *sb);
285void destroy_nilfs(struct the_nilfs *nilfs); 287void destroy_nilfs(struct the_nilfs *nilfs);
286int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data); 288int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data);
287int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb); 289int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb);