Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+68 -134
-1
fs/nilfs2/bmap.c
··· 25 25 #include <linux/errno.h> 26 26 #include "nilfs.h" 27 27 #include "bmap.h" 28 - #include "sb.h" 29 28 #include "btree.h" 30 29 #include "direct.h" 31 30 #include "btnode.h"
+1 -1
fs/nilfs2/file.c
··· 59 59 struct nilfs_transaction_info ti; 60 60 int ret; 61 61 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))) 63 63 return VM_FAULT_SIGBUS; /* -ENOSPC */ 64 64 65 65 lock_page(page);
+5 -5
fs/nilfs2/inode.c
··· 295 295 struct inode *nilfs_new_inode(struct inode *dir, int mode) 296 296 { 297 297 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; 299 299 struct inode *inode; 300 300 struct nilfs_inode_info *ii; 301 301 struct nilfs_root *root; ··· 433 433 struct nilfs_root *root, unsigned long ino, 434 434 struct inode *inode) 435 435 { 436 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 436 + struct the_nilfs *nilfs = sb->s_fs_info; 437 437 struct buffer_head *bh; 438 438 struct nilfs_inode *raw_inode; 439 439 int err; ··· 807 807 808 808 int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh) 809 809 { 810 - struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; 810 + struct the_nilfs *nilfs = inode->i_sb->s_fs_info; 811 811 struct nilfs_inode_info *ii = NILFS_I(inode); 812 812 int err; 813 813 ··· 836 836 int nilfs_inode_dirty(struct inode *inode) 837 837 { 838 838 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; 840 840 int ret = 0; 841 841 842 842 if (!list_empty(&ii->i_dirty)) { ··· 851 851 int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty) 852 852 { 853 853 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; 855 855 856 856 atomic_add(nr_dirty, &nilfs->ns_ndirtyblks); 857 857
+11 -12
fs/nilfs2/ioctl.c
··· 166 166 static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp, 167 167 unsigned int cmd, void __user *argp) 168 168 { 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; 171 170 struct nilfs_transaction_info ti; 172 171 struct nilfs_cpmode cpmode; 173 172 int ret; ··· 186 187 187 188 nilfs_transaction_begin(inode->i_sb, &ti, 0); 188 189 ret = nilfs_cpfile_change_cpmode( 189 - cpfile, cpmode.cm_cno, cpmode.cm_mode); 190 + nilfs->ns_cpfile, cpmode.cm_cno, cpmode.cm_mode); 190 191 if (unlikely(ret < 0)) 191 192 nilfs_transaction_abort(inode->i_sb); 192 193 else ··· 202 203 nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp, 203 204 unsigned int cmd, void __user *argp) 204 205 { 205 - struct inode *cpfile = NILFS_SB(inode->i_sb)->s_nilfs->ns_cpfile; 206 + struct the_nilfs *nilfs = inode->i_sb->s_fs_info; 206 207 struct nilfs_transaction_info ti; 207 208 __u64 cno; 208 209 int ret; ··· 219 220 goto out; 220 221 221 222 nilfs_transaction_begin(inode->i_sb, &ti, 0); 222 - ret = nilfs_cpfile_delete_checkpoint(cpfile, cno); 223 + ret = nilfs_cpfile_delete_checkpoint(nilfs->ns_cpfile, cno); 223 224 if (unlikely(ret < 0)) 224 225 nilfs_transaction_abort(inode->i_sb); 225 226 else ··· 245 246 static int nilfs_ioctl_get_cpstat(struct inode *inode, struct file *filp, 246 247 unsigned int cmd, void __user *argp) 247 248 { 248 - struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; 249 + struct the_nilfs *nilfs = inode->i_sb->s_fs_info; 249 250 struct nilfs_cpstat cpstat; 250 251 int ret; 251 252 ··· 276 277 static int nilfs_ioctl_get_sustat(struct inode *inode, struct file *filp, 277 278 unsigned int cmd, void __user *argp) 278 279 { 279 - struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; 280 + struct the_nilfs *nilfs = inode->i_sb->s_fs_info; 280 281 struct nilfs_sustat sustat; 281 282 int ret; 282 283 ··· 332 333 static int nilfs_ioctl_get_bdescs(struct inode *inode, struct file *filp, 333 334 unsigned int cmd, void __user *argp) 334 335 { 335 - struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; 336 + struct the_nilfs *nilfs = inode->i_sb->s_fs_info; 336 337 struct nilfs_argv argv; 337 338 int ret; 338 339 ··· 401 402 struct nilfs_argv *argv, void *buf) 402 403 { 403 404 size_t nmembs = argv->v_nmembs; 404 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 405 + struct the_nilfs *nilfs = sb->s_fs_info; 405 406 struct inode *inode; 406 407 struct nilfs_vdesc *vdesc; 407 408 struct buffer_head *bh, *n; ··· 615 616 ret = PTR_ERR(kbufs[4]); 616 617 goto out; 617 618 } 618 - nilfs = NILFS_SB(inode->i_sb)->s_nilfs; 619 + nilfs = inode->i_sb->s_fs_info; 619 620 620 621 for (n = 0; n < 4; n++) { 621 622 ret = -EINVAL; ··· 688 689 return ret; 689 690 690 691 if (argp != NULL) { 691 - nilfs = NILFS_SB(inode->i_sb)->s_nilfs; 692 + nilfs = inode->i_sb->s_fs_info; 692 693 down_read(&nilfs->ns_segctor_sem); 693 694 cno = nilfs->ns_cno - 1; 694 695 up_read(&nilfs->ns_segctor_sem); ··· 706 707 void *, size_t, size_t)) 707 708 708 709 { 709 - struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; 710 + struct the_nilfs *nilfs = inode->i_sb->s_fs_info; 710 711 struct nilfs_argv argv; 711 712 int ret; 712 713
+1 -1
fs/nilfs2/mdt.h
··· 66 66 67 67 static inline struct the_nilfs *NILFS_I_NILFS(struct inode *inode) 68 68 { 69 - return NILFS_SB(inode->i_sb)->s_nilfs; 69 + return inode->i_sb->s_fs_info; 70 70 } 71 71 72 72 /* Default GFP flags using highmem */
+1 -1
fs/nilfs2/namei.c
··· 482 482 if (ino < NILFS_FIRST_INO(sb) && ino != NILFS_ROOT_INO) 483 483 return ERR_PTR(-ESTALE); 484 484 485 - root = nilfs_lookup_root(NILFS_SB(sb)->s_nilfs, cno); 485 + root = nilfs_lookup_root(sb->s_fs_info, cno); 486 486 if (!root) 487 487 return ERR_PTR(-ESTALE); 488 488
+1 -2
fs/nilfs2/nilfs.h
··· 30 30 #include <linux/blkdev.h> 31 31 #include <linux/nilfs2_fs.h> 32 32 #include "the_nilfs.h" 33 - #include "sb.h" 34 33 #include "bmap.h" 35 34 36 35 /* ··· 121 122 #define NILFS_SYS_INO_BITS \ 122 123 ((unsigned int)(1 << NILFS_ROOT_INO) | NILFS_MDT_INO_BITS) 123 124 124 - #define NILFS_FIRST_INO(sb) (NILFS_SB(sb)->s_nilfs->ns_first_ino) 125 + #define NILFS_FIRST_INO(sb) (((struct the_nilfs *)sb->s_fs_info)->ns_first_ino) 125 126 126 127 #define NILFS_MDT_INODE(sb, ino) \ 127 128 ((ino) < NILFS_FIRST_INO(sb) && (NILFS_MDT_INO_BITS & (1 << (ino))))
-46
fs/nilfs2/sb.h
··· 1 - /* 2 - * sb.h - NILFS on-memory super block structure. 3 - * 4 - * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License as published by 8 - * the Free Software Foundation; either version 2 of the License, or 9 - * (at your option) any later version. 10 - * 11 - * This program is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 - * GNU General Public License for more details. 15 - * 16 - * You should have received a copy of the GNU General Public License 17 - * along with this program; if not, write to the Free Software 18 - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 - * 20 - * Written by Ryusuke Konishi <ryusuke@osrg.net> 21 - * 22 - */ 23 - 24 - #ifndef _NILFS_SB 25 - #define _NILFS_SB 26 - 27 - #include <linux/types.h> 28 - #include <linux/fs.h> 29 - 30 - struct the_nilfs; 31 - 32 - /* 33 - * NILFS super-block data in memory 34 - */ 35 - struct nilfs_sb_info { 36 - /* Fundamental members */ 37 - struct super_block *s_super; /* reverse pointer to super_block */ 38 - struct the_nilfs *s_nilfs; 39 - }; 40 - 41 - static inline struct nilfs_sb_info *NILFS_SB(struct super_block *sb) 42 - { 43 - return sb->s_fs_info; 44 - } 45 - 46 - #endif /* _NILFS_SB */
+24 -23
fs/nilfs2/segment.c
··· 191 191 192 192 vfs_check_frozen(sb, SB_FREEZE_WRITE); 193 193 194 - nilfs = NILFS_SB(sb)->s_nilfs; 194 + nilfs = sb->s_fs_info; 195 195 down_read(&nilfs->ns_segctor_sem); 196 196 if (vacancy_check && nilfs_near_disk_full(nilfs)) { 197 197 up_read(&nilfs->ns_segctor_sem); ··· 222 222 int nilfs_transaction_commit(struct super_block *sb) 223 223 { 224 224 struct nilfs_transaction_info *ti = current->journal_info; 225 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 225 + struct the_nilfs *nilfs = sb->s_fs_info; 226 226 int err = 0; 227 227 228 228 BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); ··· 252 252 void nilfs_transaction_abort(struct super_block *sb) 253 253 { 254 254 struct nilfs_transaction_info *ti = current->journal_info; 255 + struct the_nilfs *nilfs = sb->s_fs_info; 255 256 256 257 BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); 257 258 if (ti->ti_count > 0) { 258 259 ti->ti_count--; 259 260 return; 260 261 } 261 - up_read(&NILFS_SB(sb)->s_nilfs->ns_segctor_sem); 262 + up_read(&nilfs->ns_segctor_sem); 262 263 263 264 current->journal_info = ti->ti_save; 264 265 if (ti->ti_flags & NILFS_TI_DYNAMIC_ALLOC) ··· 268 267 269 268 void nilfs_relax_pressure_in_lock(struct super_block *sb) 270 269 { 271 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 270 + struct the_nilfs *nilfs = sb->s_fs_info; 272 271 struct nilfs_sc_info *sci = nilfs->ns_writer; 273 272 274 273 if (!sci || !sci->sc_flush_request) ··· 294 293 int gcflag) 295 294 { 296 295 struct nilfs_transaction_info *cur_ti = current->journal_info; 297 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 296 + struct the_nilfs *nilfs = sb->s_fs_info; 298 297 struct nilfs_sc_info *sci = nilfs->ns_writer; 299 298 300 299 WARN_ON(cur_ti); ··· 322 321 static void nilfs_transaction_unlock(struct super_block *sb) 323 322 { 324 323 struct nilfs_transaction_info *ti = current->journal_info; 325 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 324 + struct the_nilfs *nilfs = sb->s_fs_info; 326 325 327 326 BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); 328 327 BUG_ON(ti->ti_count > 0); ··· 771 770 772 771 static int nilfs_segctor_confirm(struct nilfs_sc_info *sci) 773 772 { 774 - struct the_nilfs *nilfs = NILFS_SB(sci->sc_super)->s_nilfs; 773 + struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 775 774 int ret = 0; 776 775 777 776 if (nilfs_test_metadata_dirty(nilfs, sci->sc_root)) ··· 787 786 788 787 static void nilfs_segctor_clear_metadata_dirty(struct nilfs_sc_info *sci) 789 788 { 790 - struct the_nilfs *nilfs = NILFS_SB(sci->sc_super)->s_nilfs; 789 + struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 791 790 792 791 nilfs_mdt_clear_dirty(sci->sc_root->ifile); 793 792 nilfs_mdt_clear_dirty(nilfs->ns_cpfile); ··· 797 796 798 797 static int nilfs_segctor_create_checkpoint(struct nilfs_sc_info *sci) 799 798 { 800 - struct the_nilfs *nilfs = NILFS_SB(sci->sc_super)->s_nilfs; 799 + struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 801 800 struct buffer_head *bh_cp; 802 801 struct nilfs_checkpoint *raw_cp; 803 802 int err; ··· 821 820 822 821 static int nilfs_segctor_fill_in_checkpoint(struct nilfs_sc_info *sci) 823 822 { 824 - struct the_nilfs *nilfs = NILFS_SB(sci->sc_super)->s_nilfs; 823 + struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 825 824 struct buffer_head *bh_cp; 826 825 struct nilfs_checkpoint *raw_cp; 827 826 int err; ··· 1045 1044 1046 1045 static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode) 1047 1046 { 1048 - struct the_nilfs *nilfs = NILFS_SB(sci->sc_super)->s_nilfs; 1047 + struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 1049 1048 struct list_head *head; 1050 1049 struct nilfs_inode_info *ii; 1051 1050 size_t ndone; ··· 1854 1853 { 1855 1854 struct nilfs_segment_buffer *segbuf; 1856 1855 struct page *bd_page = NULL, *fs_page = NULL; 1857 - struct the_nilfs *nilfs = NILFS_SB(sci->sc_super)->s_nilfs; 1856 + struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 1858 1857 int update_sr = false; 1859 1858 1860 1859 list_for_each_entry(segbuf, &sci->sc_write_logs, sb_list) { ··· 2025 2024 */ 2026 2025 static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) 2027 2026 { 2028 - struct the_nilfs *nilfs = NILFS_SB(sci->sc_super)->s_nilfs; 2027 + struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 2029 2028 struct page *failed_page; 2030 2029 int err; 2031 2030 ··· 2163 2162 */ 2164 2163 void nilfs_flush_segment(struct super_block *sb, ino_t ino) 2165 2164 { 2166 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 2165 + struct the_nilfs *nilfs = sb->s_fs_info; 2167 2166 struct nilfs_sc_info *sci = nilfs->ns_writer; 2168 2167 2169 2168 if (!sci || nilfs_doing_construction()) ··· 2253 2252 */ 2254 2253 int nilfs_construct_segment(struct super_block *sb) 2255 2254 { 2256 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 2255 + struct the_nilfs *nilfs = sb->s_fs_info; 2257 2256 struct nilfs_sc_info *sci = nilfs->ns_writer; 2258 2257 struct nilfs_transaction_info *ti; 2259 2258 int err; ··· 2291 2290 int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, 2292 2291 loff_t start, loff_t end) 2293 2292 { 2294 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 2293 + struct the_nilfs *nilfs = sb->s_fs_info; 2295 2294 struct nilfs_sc_info *sci = nilfs->ns_writer; 2296 2295 struct nilfs_inode_info *ii; 2297 2296 struct nilfs_transaction_info ti; ··· 2382 2381 */ 2383 2382 static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode) 2384 2383 { 2385 - struct the_nilfs *nilfs = NILFS_SB(sci->sc_super)->s_nilfs; 2384 + struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 2386 2385 struct nilfs_super_block **sbp; 2387 2386 int err = 0; 2388 2387 ··· 2437 2436 int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, 2438 2437 void **kbufs) 2439 2438 { 2440 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 2439 + struct the_nilfs *nilfs = sb->s_fs_info; 2441 2440 struct nilfs_sc_info *sci = nilfs->ns_writer; 2442 2441 struct nilfs_transaction_info ti; 2443 2442 int err; ··· 2553 2552 static int nilfs_segctor_thread(void *arg) 2554 2553 { 2555 2554 struct nilfs_sc_info *sci = (struct nilfs_sc_info *)arg; 2556 - struct the_nilfs *nilfs = NILFS_SB(sci->sc_super)->s_nilfs; 2555 + struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 2557 2556 int timeout = 0; 2558 2557 2559 2558 sci->sc_timer.data = (unsigned long)current; ··· 2667 2666 static struct nilfs_sc_info *nilfs_segctor_new(struct super_block *sb, 2668 2667 struct nilfs_root *root) 2669 2668 { 2670 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 2669 + struct the_nilfs *nilfs = sb->s_fs_info; 2671 2670 struct nilfs_sc_info *sci; 2672 2671 2673 2672 sci = kzalloc(sizeof(*sci), GFP_KERNEL); ··· 2727 2726 */ 2728 2727 static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) 2729 2728 { 2730 - struct the_nilfs *nilfs = NILFS_SB(sci->sc_super)->s_nilfs; 2729 + struct the_nilfs *nilfs = sci->sc_super->s_fs_info; 2731 2730 int flag; 2732 2731 2733 2732 up_write(&nilfs->ns_segctor_sem); ··· 2775 2774 */ 2776 2775 int nilfs_attach_log_writer(struct super_block *sb, struct nilfs_root *root) 2777 2776 { 2778 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 2777 + struct the_nilfs *nilfs = sb->s_fs_info; 2779 2778 int err; 2780 2779 2781 2780 if (nilfs->ns_writer) { ··· 2808 2807 */ 2809 2808 void nilfs_detach_log_writer(struct super_block *sb) 2810 2809 { 2811 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 2810 + struct the_nilfs *nilfs = sb->s_fs_info; 2812 2811 LIST_HEAD(garbage_list); 2813 2812 2814 2813 down_write(&nilfs->ns_segctor_sem);
+1 -1
fs/nilfs2/segment.h
··· 27 27 #include <linux/fs.h> 28 28 #include <linux/buffer_head.h> 29 29 #include <linux/nilfs2_fs.h> 30 - #include "sb.h" 30 + #include "nilfs.h" 31 31 32 32 struct nilfs_root; 33 33
+23 -40
fs/nilfs2/super.c
··· 76 76 77 77 static void nilfs_set_error(struct super_block *sb) 78 78 { 79 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 79 + struct the_nilfs *nilfs = sb->s_fs_info; 80 80 struct nilfs_super_block **sbp; 81 81 82 82 down_write(&nilfs->ns_sem); ··· 108 108 void nilfs_error(struct super_block *sb, const char *function, 109 109 const char *fmt, ...) 110 110 { 111 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 111 + struct the_nilfs *nilfs = sb->s_fs_info; 112 112 struct va_format vaf; 113 113 va_list args; 114 114 ··· 190 190 191 191 static int nilfs_sync_super(struct super_block *sb, int flag) 192 192 { 193 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 193 + struct the_nilfs *nilfs = sb->s_fs_info; 194 194 int err; 195 195 196 196 retry: ··· 265 265 struct nilfs_super_block **nilfs_prepare_super(struct super_block *sb, 266 266 int flip) 267 267 { 268 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 268 + struct the_nilfs *nilfs = sb->s_fs_info; 269 269 struct nilfs_super_block **sbp = nilfs->ns_sbp; 270 270 271 271 /* nilfs->ns_sem must be locked by the caller. */ ··· 291 291 292 292 int nilfs_commit_super(struct super_block *sb, int flag) 293 293 { 294 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 294 + struct the_nilfs *nilfs = sb->s_fs_info; 295 295 struct nilfs_super_block **sbp = nilfs->ns_sbp; 296 296 time_t t; 297 297 ··· 324 324 */ 325 325 int nilfs_cleanup_super(struct super_block *sb) 326 326 { 327 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 327 + struct the_nilfs *nilfs = sb->s_fs_info; 328 328 struct nilfs_super_block **sbp; 329 329 int flag = NILFS_SB_COMMIT; 330 330 int ret = -EIO; ··· 349 349 350 350 static void nilfs_put_super(struct super_block *sb) 351 351 { 352 - struct nilfs_sb_info *sbi = NILFS_SB(sb); 353 - struct the_nilfs *nilfs = sbi->s_nilfs; 352 + struct the_nilfs *nilfs = sb->s_fs_info; 354 353 355 354 nilfs_detach_log_writer(sb); 356 355 ··· 364 365 iput(nilfs->ns_dat); 365 366 366 367 destroy_nilfs(nilfs); 367 - sbi->s_super = NULL; 368 368 sb->s_fs_info = NULL; 369 - kfree(sbi); 370 369 } 371 370 372 371 static int nilfs_sync_fs(struct super_block *sb, int wait) 373 372 { 374 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 373 + struct the_nilfs *nilfs = sb->s_fs_info; 375 374 struct nilfs_super_block **sbp; 376 375 int err = 0; 377 376 ··· 393 396 int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt, 394 397 struct nilfs_root **rootp) 395 398 { 396 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 399 + struct the_nilfs *nilfs = sb->s_fs_info; 397 400 struct nilfs_root *root; 398 401 struct nilfs_checkpoint *raw_cp; 399 402 struct buffer_head *bh_cp; ··· 446 449 447 450 static int nilfs_freeze(struct super_block *sb) 448 451 { 449 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 452 + struct the_nilfs *nilfs = sb->s_fs_info; 450 453 int err; 451 454 452 455 if (sb->s_flags & MS_RDONLY) ··· 461 464 462 465 static int nilfs_unfreeze(struct super_block *sb) 463 466 { 464 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 467 + struct the_nilfs *nilfs = sb->s_fs_info; 465 468 466 469 if (sb->s_flags & MS_RDONLY) 467 470 return 0; ··· 524 527 static int nilfs_show_options(struct seq_file *seq, struct vfsmount *vfs) 525 528 { 526 529 struct super_block *sb = vfs->mnt_sb; 527 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 530 + struct the_nilfs *nilfs = sb->s_fs_info; 528 531 struct nilfs_root *root = NILFS_I(vfs->mnt_root->d_inode)->i_root; 529 532 530 533 if (!nilfs_test_opt(nilfs, BARRIER)) ··· 588 591 589 592 static int parse_options(char *options, struct super_block *sb, int is_remount) 590 593 { 591 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 594 + struct the_nilfs *nilfs = sb->s_fs_info; 592 595 char *p; 593 596 substring_t args[MAX_OPT_ARGS]; 594 597 ··· 657 660 nilfs_set_default_options(struct super_block *sb, 658 661 struct nilfs_super_block *sbp) 659 662 { 660 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 663 + struct the_nilfs *nilfs = sb->s_fs_info; 661 664 662 665 nilfs->ns_mount_opt = 663 666 NILFS_MOUNT_ERRORS_RO | NILFS_MOUNT_BARRIER; ··· 665 668 666 669 static int nilfs_setup_super(struct super_block *sb, int is_mount) 667 670 { 668 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 671 + struct the_nilfs *nilfs = sb->s_fs_info; 669 672 struct nilfs_super_block **sbp; 670 673 int max_mnt_count; 671 674 int mnt_count; ··· 723 726 struct nilfs_super_block *sbp, 724 727 char *data) 725 728 { 726 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 729 + struct the_nilfs *nilfs = sb->s_fs_info; 727 730 728 731 sb->s_magic = le16_to_cpu(sbp->s_magic); 729 732 ··· 818 821 static int nilfs_attach_snapshot(struct super_block *s, __u64 cno, 819 822 struct dentry **root_dentry) 820 823 { 821 - struct the_nilfs *nilfs = NILFS_SB(s)->s_nilfs; 824 + struct the_nilfs *nilfs = s->s_fs_info; 822 825 struct nilfs_root *root; 823 826 int ret; 824 827 ··· 870 873 871 874 int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno) 872 875 { 873 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 876 + struct the_nilfs *nilfs = sb->s_fs_info; 874 877 struct nilfs_root *root; 875 878 struct inode *inode; 876 879 struct dentry *dentry; ··· 883 886 return true; /* protect recent checkpoints */ 884 887 885 888 ret = false; 886 - root = nilfs_lookup_root(NILFS_SB(sb)->s_nilfs, cno); 889 + root = nilfs_lookup_root(nilfs, cno); 887 890 if (root) { 888 891 inode = nilfs_ilookup(sb, root, NILFS_ROOT_INO); 889 892 if (inode) { ··· 913 916 nilfs_fill_super(struct super_block *sb, void *data, int silent) 914 917 { 915 918 struct the_nilfs *nilfs; 916 - struct nilfs_sb_info *sbi; 917 919 struct nilfs_root *fsroot; 918 920 struct backing_dev_info *bdi; 919 921 __u64 cno; 920 922 int err; 921 923 922 - sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 923 - if (!sbi) 924 + nilfs = alloc_nilfs(sb->s_bdev); 925 + if (!nilfs) 924 926 return -ENOMEM; 925 927 926 - sb->s_fs_info = sbi; 927 - sbi->s_super = sb; 928 - 929 - nilfs = alloc_nilfs(sb->s_bdev); 930 - if (!nilfs) { 931 - err = -ENOMEM; 932 - goto failed_sbi; 933 - } 934 - sbi->s_nilfs = nilfs; 928 + sb->s_fs_info = nilfs; 935 929 936 930 err = init_nilfs(nilfs, sb, (char *)data); 937 931 if (err) ··· 981 993 982 994 failed_nilfs: 983 995 destroy_nilfs(nilfs); 984 - 985 - failed_sbi: 986 - sb->s_fs_info = NULL; 987 - kfree(sbi); 988 996 return err; 989 997 } 990 998 991 999 static int nilfs_remount(struct super_block *sb, int *flags, char *data) 992 1000 { 993 - struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 1001 + struct the_nilfs *nilfs = sb->s_fs_info; 994 1002 unsigned long old_sb_flags; 995 1003 unsigned long old_mount_opt; 996 1004 int err; ··· 1067 1083 1068 1084 struct nilfs_super_data { 1069 1085 struct block_device *bdev; 1070 - struct nilfs_sb_info *sbi; 1071 1086 __u64 cno; 1072 1087 int flags; 1073 1088 };
-1
fs/nilfs2/the_nilfs.h
··· 31 31 #include <linux/blkdev.h> 32 32 #include <linux/backing-dev.h> 33 33 #include <linux/slab.h> 34 - #include "sb.h" 35 34 36 35 struct nilfs_sc_info; 37 36