Skip to content

Commit

Permalink
nilfs2: embed a back pointer to super block instance in nilfs object
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
konis authored and torvalds committed Aug 2, 2016
1 parent a66dfb0 commit 6625689
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fs/nilfs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent)
__u64 cno;
int err;

nilfs = alloc_nilfs(sb->s_bdev);
nilfs = alloc_nilfs(sb);
if (!nilfs)
return -ENOMEM;

Expand Down
7 changes: 4 additions & 3 deletions fs/nilfs2/the_nilfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,21 @@ void nilfs_set_last_segment(struct the_nilfs *nilfs,

/**
* alloc_nilfs - allocate a nilfs object
* @bdev: block device to which the_nilfs is related
* @sb: super block instance
*
* Return Value: On success, pointer to the_nilfs is returned.
* On error, NULL is returned.
*/
struct the_nilfs *alloc_nilfs(struct block_device *bdev)
struct the_nilfs *alloc_nilfs(struct super_block *sb)
{
struct the_nilfs *nilfs;

nilfs = kzalloc(sizeof(*nilfs), GFP_KERNEL);
if (!nilfs)
return NULL;

nilfs->ns_bdev = bdev;
nilfs->ns_sb = sb;
nilfs->ns_bdev = sb->s_bdev;
atomic_set(&nilfs->ns_ndirtyblks, 0);
init_rwsem(&nilfs->ns_sem);
mutex_init(&nilfs->ns_snapshot_mount_mutex);
Expand Down
4 changes: 3 additions & 1 deletion fs/nilfs2/the_nilfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum {
* struct the_nilfs - struct to supervise multiple nilfs mount points
* @ns_flags: flags
* @ns_flushed_device: flag indicating if all volatile data was flushed
* @ns_sb: back pointer to super block instance
* @ns_bdev: block device
* @ns_sem: semaphore for shared states
* @ns_snapshot_mount_mutex: mutex to protect snapshot mounts
Expand Down Expand Up @@ -102,6 +103,7 @@ struct the_nilfs {
unsigned long ns_flags;
int ns_flushed_device;

struct super_block *ns_sb;
struct block_device *ns_bdev;
struct rw_semaphore ns_sem;
struct mutex ns_snapshot_mount_mutex;
Expand Down Expand Up @@ -281,7 +283,7 @@ static inline int nilfs_sb_will_flip(struct the_nilfs *nilfs)
}

void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64);
struct the_nilfs *alloc_nilfs(struct block_device *bdev);
struct the_nilfs *alloc_nilfs(struct super_block *sb);
void destroy_nilfs(struct the_nilfs *nilfs);
int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data);
int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb);
Expand Down

0 comments on commit 6625689

Please sign in to comment.