Skip to content

Commit 6625689

Browse files
konistorvalds
authored andcommitted
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/[email protected] Signed-off-by: Ryusuke Konishi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent a66dfb0 commit 6625689

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

fs/nilfs2/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent)
10761076
__u64 cno;
10771077
int err;
10781078

1079-
nilfs = alloc_nilfs(sb->s_bdev);
1079+
nilfs = alloc_nilfs(sb);
10801080
if (!nilfs)
10811081
return -ENOMEM;
10821082

fs/nilfs2/the_nilfs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,21 @@ void nilfs_set_last_segment(struct the_nilfs *nilfs,
5656

5757
/**
5858
* alloc_nilfs - allocate a nilfs object
59-
* @bdev: block device to which the_nilfs is related
59+
* @sb: super block instance
6060
*
6161
* Return Value: On success, pointer to the_nilfs is returned.
6262
* On error, NULL is returned.
6363
*/
64-
struct the_nilfs *alloc_nilfs(struct block_device *bdev)
64+
struct the_nilfs *alloc_nilfs(struct super_block *sb)
6565
{
6666
struct the_nilfs *nilfs;
6767

6868
nilfs = kzalloc(sizeof(*nilfs), GFP_KERNEL);
6969
if (!nilfs)
7070
return NULL;
7171

72-
nilfs->ns_bdev = bdev;
72+
nilfs->ns_sb = sb;
73+
nilfs->ns_bdev = sb->s_bdev;
7374
atomic_set(&nilfs->ns_ndirtyblks, 0);
7475
init_rwsem(&nilfs->ns_sem);
7576
mutex_init(&nilfs->ns_snapshot_mount_mutex);

fs/nilfs2/the_nilfs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum {
4343
* struct the_nilfs - struct to supervise multiple nilfs mount points
4444
* @ns_flags: flags
4545
* @ns_flushed_device: flag indicating if all volatile data was flushed
46+
* @ns_sb: back pointer to super block instance
4647
* @ns_bdev: block device
4748
* @ns_sem: semaphore for shared states
4849
* @ns_snapshot_mount_mutex: mutex to protect snapshot mounts
@@ -102,6 +103,7 @@ struct the_nilfs {
102103
unsigned long ns_flags;
103104
int ns_flushed_device;
104105

106+
struct super_block *ns_sb;
105107
struct block_device *ns_bdev;
106108
struct rw_semaphore ns_sem;
107109
struct mutex ns_snapshot_mount_mutex;
@@ -281,7 +283,7 @@ static inline int nilfs_sb_will_flip(struct the_nilfs *nilfs)
281283
}
282284

283285
void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64);
284-
struct the_nilfs *alloc_nilfs(struct block_device *bdev);
286+
struct the_nilfs *alloc_nilfs(struct super_block *sb);
285287
void destroy_nilfs(struct the_nilfs *nilfs);
286288
int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data);
287289
int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb);

0 commit comments

Comments
 (0)