the_nilfs.c (6dd4740662405a68bb229ac2b9e0aeaaf2188bf2) | the_nilfs.c (e59399d0102c1813cec48db5cebe1750313f88a0) |
---|---|
1/* 2 * the_nilfs.c - the_nilfs shared 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 --- 58 unchanged lines hidden (view full) --- 67 if (!nilfs) 68 return NULL; 69 70 nilfs->ns_bdev = bdev; 71 atomic_set(&nilfs->ns_count, 1); 72 atomic_set(&nilfs->ns_writer_refcount, -1); 73 atomic_set(&nilfs->ns_ndirtyblks, 0); 74 init_rwsem(&nilfs->ns_sem); | 1/* 2 * the_nilfs.c - the_nilfs shared 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 --- 58 unchanged lines hidden (view full) --- 67 if (!nilfs) 68 return NULL; 69 70 nilfs->ns_bdev = bdev; 71 atomic_set(&nilfs->ns_count, 1); 72 atomic_set(&nilfs->ns_writer_refcount, -1); 73 atomic_set(&nilfs->ns_ndirtyblks, 0); 74 init_rwsem(&nilfs->ns_sem); |
75 init_rwsem(&nilfs->ns_super_sem); |
|
75 mutex_init(&nilfs->ns_writer_mutex); 76 INIT_LIST_HEAD(&nilfs->ns_list); 77 INIT_LIST_HEAD(&nilfs->ns_supers); 78 spin_lock_init(&nilfs->ns_last_segment_lock); 79 nilfs->ns_gc_inodes_h = NULL; 80 init_rwsem(&nilfs->ns_segctor_sem); 81 82 return nilfs; --- 593 unchanged lines hidden (view full) --- 676 * be unmounted after this function returns, the nilfs_sb_info struct 677 * is kept on memory until nilfs_put_sbinfo() is called. 678 */ 679struct nilfs_sb_info *nilfs_find_sbinfo(struct the_nilfs *nilfs, 680 int rw_mount, __u64 cno) 681{ 682 struct nilfs_sb_info *sbi; 683 | 76 mutex_init(&nilfs->ns_writer_mutex); 77 INIT_LIST_HEAD(&nilfs->ns_list); 78 INIT_LIST_HEAD(&nilfs->ns_supers); 79 spin_lock_init(&nilfs->ns_last_segment_lock); 80 nilfs->ns_gc_inodes_h = NULL; 81 init_rwsem(&nilfs->ns_segctor_sem); 82 83 return nilfs; --- 593 unchanged lines hidden (view full) --- 677 * be unmounted after this function returns, the nilfs_sb_info struct 678 * is kept on memory until nilfs_put_sbinfo() is called. 679 */ 680struct nilfs_sb_info *nilfs_find_sbinfo(struct the_nilfs *nilfs, 681 int rw_mount, __u64 cno) 682{ 683 struct nilfs_sb_info *sbi; 684 |
684 down_read(&nilfs->ns_sem); | 685 down_read(&nilfs->ns_super_sem); |
685 /* 686 * The SNAPSHOT flag and sb->s_flags are supposed to be | 686 /* 687 * The SNAPSHOT flag and sb->s_flags are supposed to be |
687 * protected with nilfs->ns_sem. | 688 * protected with nilfs->ns_super_sem. |
688 */ 689 sbi = nilfs->ns_current; 690 if (rw_mount) { 691 if (sbi && !(sbi->s_super->s_flags & MS_RDONLY)) 692 goto found; /* read/write mount */ 693 else 694 goto out; 695 } else if (cno == 0) { --- 4 unchanged lines hidden (view full) --- 700 } 701 702 list_for_each_entry(sbi, &nilfs->ns_supers, s_list) { 703 if (nilfs_test_opt(sbi, SNAPSHOT) && 704 sbi->s_snapshot_cno == cno) 705 goto found; /* snapshot mount */ 706 } 707 out: | 689 */ 690 sbi = nilfs->ns_current; 691 if (rw_mount) { 692 if (sbi && !(sbi->s_super->s_flags & MS_RDONLY)) 693 goto found; /* read/write mount */ 694 else 695 goto out; 696 } else if (cno == 0) { --- 4 unchanged lines hidden (view full) --- 701 } 702 703 list_for_each_entry(sbi, &nilfs->ns_supers, s_list) { 704 if (nilfs_test_opt(sbi, SNAPSHOT) && 705 sbi->s_snapshot_cno == cno) 706 goto found; /* snapshot mount */ 707 } 708 out: |
708 up_read(&nilfs->ns_sem); | 709 up_read(&nilfs->ns_super_sem); |
709 return NULL; 710 711 found: 712 atomic_inc(&sbi->s_count); | 710 return NULL; 711 712 found: 713 atomic_inc(&sbi->s_count); |
713 up_read(&nilfs->ns_sem); | 714 up_read(&nilfs->ns_super_sem); |
714 return sbi; 715} 716 717int nilfs_checkpoint_is_mounted(struct the_nilfs *nilfs, __u64 cno, 718 int snapshot_mount) 719{ 720 struct nilfs_sb_info *sbi; 721 int ret = 0; 722 | 715 return sbi; 716} 717 718int nilfs_checkpoint_is_mounted(struct the_nilfs *nilfs, __u64 cno, 719 int snapshot_mount) 720{ 721 struct nilfs_sb_info *sbi; 722 int ret = 0; 723 |
723 down_read(&nilfs->ns_sem); | 724 down_read(&nilfs->ns_super_sem); |
724 if (cno == 0 || cno > nilfs->ns_cno) 725 goto out_unlock; 726 727 list_for_each_entry(sbi, &nilfs->ns_supers, s_list) { 728 if (sbi->s_snapshot_cno == cno && 729 (!snapshot_mount || nilfs_test_opt(sbi, SNAPSHOT))) { 730 /* exclude read-only mounts */ 731 ret++; 732 break; 733 } 734 } 735 /* for protecting recent checkpoints */ 736 if (cno >= nilfs_last_cno(nilfs)) 737 ret++; 738 739 out_unlock: | 725 if (cno == 0 || cno > nilfs->ns_cno) 726 goto out_unlock; 727 728 list_for_each_entry(sbi, &nilfs->ns_supers, s_list) { 729 if (sbi->s_snapshot_cno == cno && 730 (!snapshot_mount || nilfs_test_opt(sbi, SNAPSHOT))) { 731 /* exclude read-only mounts */ 732 ret++; 733 break; 734 } 735 } 736 /* for protecting recent checkpoints */ 737 if (cno >= nilfs_last_cno(nilfs)) 738 ret++; 739 740 out_unlock: |
740 up_read(&nilfs->ns_sem); | 741 up_read(&nilfs->ns_super_sem); |
741 return ret; 742} | 742 return ret; 743} |