Skip to content

Commit e3154e9

Browse files
committed
nilfs2: get rid of nilfs_sb_info structure
This directly uses sb->s_fs_info to keep a nilfs filesystem object and fully removes the intermediate nilfs_sb_info structure. With this change, the hierarchy of on-memory structures of nilfs will be simplified as follows: Before: super_block -> nilfs_sb_info -> the_nilfs -> cptree --+-> nilfs_root (current file system) +-> nilfs_root (snapshot A) +-> nilfs_root (snapshot B) : -> nilfs_sc_info (log writer structure) After: super_block -> the_nilfs -> cptree --+-> nilfs_root (current file system) +-> nilfs_root (snapshot A) +-> nilfs_root (snapshot B) : -> nilfs_sc_info (log writer structure) The reason why we didn't design so from the beginning is because the initial shape also differed from the above. The early hierachy was composed of "per-mount-point" super_block -> nilfs_sb_info pairs and a shared nilfs object. On the kernel 2.6.37, it was changed to the current shape in order to unify super block instances into one per device, and this cleanup became applicable as the result. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
1 parent f754514 commit e3154e9

12 files changed

Lines changed: 68 additions & 134 deletions

File tree

‎fs/nilfs2/bmap.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <linux/errno.h>
2626
#include "nilfs.h"
2727
#include "bmap.h"
28-
#include "sb.h"
2928
#include "btree.h"
3029
#include "direct.h"
3130
#include "btnode.h"

‎fs/nilfs2/file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
5959
struct nilfs_transaction_info ti;
6060
int ret;
6161

62-
if (unlikely(nilfs_near_disk_full(NILFS_SB(inode->i_sb)->s_nilfs)))
62+
if (unlikely(nilfs_near_disk_full(inode->i_sb->s_fs_info)))
6363
return VM_FAULT_SIGBUS; /* -ENOSPC */
6464

6565
lock_page(page);

‎fs/nilfs2/inode.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ const struct address_space_operations nilfs_aops = {
295295
struct inode *nilfs_new_inode(struct inode *dir, int mode)
296296
{
297297
struct super_block *sb = dir->i_sb;
298-
struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
298+
struct the_nilfs *nilfs = sb->s_fs_info;
299299
struct inode *inode;
300300
struct nilfs_inode_info *ii;
301301
struct nilfs_root *root;
@@ -433,7 +433,7 @@ static int __nilfs_read_inode(struct super_block *sb,
433433
struct nilfs_root *root, unsigned long ino,
434434
struct inode *inode)
435435
{
436-
struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
436+
struct the_nilfs *nilfs = sb->s_fs_info;
437437
struct buffer_head *bh;
438438
struct nilfs_inode *raw_inode;
439439
int err;
@@ -807,7 +807,7 @@ int nilfs_permission(struct inode *inode, int mask, unsigned int flags)
807807

808808
int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh)
809809
{
810-
struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
810+
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
811811
struct nilfs_inode_info *ii = NILFS_I(inode);
812812
int err;
813813

@@ -836,7 +836,7 @@ int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh)
836836
int nilfs_inode_dirty(struct inode *inode)
837837
{
838838
struct nilfs_inode_info *ii = NILFS_I(inode);
839-
struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
839+
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
840840
int ret = 0;
841841

842842
if (!list_empty(&ii->i_dirty)) {
@@ -851,7 +851,7 @@ int nilfs_inode_dirty(struct inode *inode)
851851
int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty)
852852
{
853853
struct nilfs_inode_info *ii = NILFS_I(inode);
854-
struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
854+
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
855855

856856
atomic_add(nr_dirty, &nilfs->ns_ndirtyblks);
857857

‎fs/nilfs2/ioctl.c‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ static int nilfs_ioctl_getversion(struct inode *inode, void __user *argp)
166166
static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp,
167167
unsigned int cmd, void __user *argp)
168168
{
169-
struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
170-
struct inode *cpfile = nilfs->ns_cpfile;
169+
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
171170
struct nilfs_transaction_info ti;
172171
struct nilfs_cpmode cpmode;
173172
int ret;
@@ -187,7 +186,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp,
187186

188187
nilfs_transaction_begin(inode->i_sb, &ti, 0);
189188
ret = nilfs_cpfile_change_cpmode(
190-
cpfile, cpmode.cm_cno, cpmode.cm_mode);
189+
nilfs->ns_cpfile, cpmode.cm_cno, cpmode.cm_mode);
191190
if (unlikely(ret < 0))
192191
nilfs_transaction_abort(inode->i_sb);
193192
else
@@ -203,7 +202,7 @@ static int
203202
nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp,
204203
unsigned int cmd, void __user *argp)
205204
{
206-
struct inode *cpfile = NILFS_SB(inode->i_sb)->s_nilfs->ns_cpfile;
205+
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
207206
struct nilfs_transaction_info ti;
208207
__u64 cno;
209208
int ret;
@@ -220,7 +219,7 @@ nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp,
220219
goto out;
221220

222221
nilfs_transaction_begin(inode->i_sb, &ti, 0);
223-
ret = nilfs_cpfile_delete_checkpoint(cpfile, cno);
222+
ret = nilfs_cpfile_delete_checkpoint(nilfs->ns_cpfile, cno);
224223
if (unlikely(ret < 0))
225224
nilfs_transaction_abort(inode->i_sb);
226225
else
@@ -246,7 +245,7 @@ nilfs_ioctl_do_get_cpinfo(struct the_nilfs *nilfs, __u64 *posp, int flags,
246245
static int nilfs_ioctl_get_cpstat(struct inode *inode, struct file *filp,
247246
unsigned int cmd, void __user *argp)
248247
{
249-
struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
248+
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
250249
struct nilfs_cpstat cpstat;
251250
int ret;
252251

@@ -277,7 +276,7 @@ nilfs_ioctl_do_get_suinfo(struct the_nilfs *nilfs, __u64 *posp, int flags,
277276
static int nilfs_ioctl_get_sustat(struct inode *inode, struct file *filp,
278277
unsigned int cmd, void __user *argp)
279278
{
280-
struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
279+
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
281280
struct nilfs_sustat sustat;
282281
int ret;
283282

@@ -333,7 +332,7 @@ nilfs_ioctl_do_get_bdescs(struct the_nilfs *nilfs, __u64 *posp, int flags,
333332
static int nilfs_ioctl_get_bdescs(struct inode *inode, struct file *filp,
334333
unsigned int cmd, void __user *argp)
335334
{
336-
struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
335+
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
337336
struct nilfs_argv argv;
338337
int ret;
339338

@@ -402,7 +401,7 @@ static int nilfs_ioctl_move_blocks(struct super_block *sb,
402401
struct nilfs_argv *argv, void *buf)
403402
{
404403
size_t nmembs = argv->v_nmembs;
405-
struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
404+
struct the_nilfs *nilfs = sb->s_fs_info;
406405
struct inode *inode;
407406
struct nilfs_vdesc *vdesc;
408407
struct buffer_head *bh, *n;
@@ -616,7 +615,7 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
616615
ret = PTR_ERR(kbufs[4]);
617616
goto out;
618617
}
619-
nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
618+
nilfs = inode->i_sb->s_fs_info;
620619

621620
for (n = 0; n < 4; n++) {
622621
ret = -EINVAL;
@@ -689,7 +688,7 @@ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
689688
return ret;
690689

691690
if (argp != NULL) {
692-
nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
691+
nilfs = inode->i_sb->s_fs_info;
693692
down_read(&nilfs->ns_segctor_sem);
694693
cno = nilfs->ns_cno - 1;
695694
up_read(&nilfs->ns_segctor_sem);
@@ -707,7 +706,7 @@ static int nilfs_ioctl_get_info(struct inode *inode, struct file *filp,
707706
void *, size_t, size_t))
708707

709708
{
710-
struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
709+
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
711710
struct nilfs_argv argv;
712711
int ret;
713712

‎fs/nilfs2/mdt.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static inline struct nilfs_mdt_info *NILFS_MDT(const struct inode *inode)
6666

6767
static inline struct the_nilfs *NILFS_I_NILFS(struct inode *inode)
6868
{
69-
return NILFS_SB(inode->i_sb)->s_nilfs;
69+
return inode->i_sb->s_fs_info;
7070
}
7171

7272
/* Default GFP flags using highmem */

‎fs/nilfs2/namei.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ static struct dentry *nilfs_get_dentry(struct super_block *sb, u64 cno,
482482
if (ino < NILFS_FIRST_INO(sb) && ino != NILFS_ROOT_INO)
483483
return ERR_PTR(-ESTALE);
484484

485-
root = nilfs_lookup_root(NILFS_SB(sb)->s_nilfs, cno);
485+
root = nilfs_lookup_root(sb->s_fs_info, cno);
486486
if (!root)
487487
return ERR_PTR(-ESTALE);
488488

‎fs/nilfs2/nilfs.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <linux/blkdev.h>
3131
#include <linux/nilfs2_fs.h>
3232
#include "the_nilfs.h"
33-
#include "sb.h"
3433
#include "bmap.h"
3534

3635
/*
@@ -122,7 +121,7 @@ enum {
122121
#define NILFS_SYS_INO_BITS \
123122
((unsigned int)(1 << NILFS_ROOT_INO) | NILFS_MDT_INO_BITS)
124123

125-
#define NILFS_FIRST_INO(sb) (NILFS_SB(sb)->s_nilfs->ns_first_ino)
124+
#define NILFS_FIRST_INO(sb) (((struct the_nilfs *)sb->s_fs_info)->ns_first_ino)
126125

127126
#define NILFS_MDT_INODE(sb, ino) \
128127
((ino) < NILFS_FIRST_INO(sb) && (NILFS_MDT_INO_BITS & (1 << (ino))))

‎fs/nilfs2/sb.h‎

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)