diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-01-22 14:33:40 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-01-22 14:33:40 -0500 |
commit | 2596627c5c30b45aa206b7b1b864bf00de3c3503 (patch) | |
tree | 28efd5977acccb330afd886c440430e22b8916ae | |
parent | 19e805cb040a81dcfbcf2aa8dbe5d9454c5faf2d (diff) | |
parent | 50af94b14c98f5769860a282a397c6f3b135c8a8 (diff) |
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2:
ocfs2: Add backup superblock info to ocfs2_fs.h
ocfs2: cleanup ocfs2_iget() errors
ocfs2: Directory c/mtime update fixes
ocfs2: Don't print errors when following symlinks
-rw-r--r-- | fs/ocfs2/export.c | 5 | ||||
-rw-r--r-- | fs/ocfs2/inode.c | 11 | ||||
-rw-r--r-- | fs/ocfs2/namei.c | 69 | ||||
-rw-r--r-- | fs/ocfs2/ocfs2_fs.h | 43 | ||||
-rw-r--r-- | fs/ocfs2/symlink.c | 3 |
5 files changed, 84 insertions, 47 deletions
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c index 06be6e774cf9..56e1fefc1205 100644 --- a/fs/ocfs2/export.c +++ b/fs/ocfs2/export.c | |||
@@ -60,14 +60,11 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, void *vobjp) | |||
60 | 60 | ||
61 | inode = ocfs2_iget(OCFS2_SB(sb), handle->ih_blkno, 0); | 61 | inode = ocfs2_iget(OCFS2_SB(sb), handle->ih_blkno, 0); |
62 | 62 | ||
63 | if (IS_ERR(inode)) { | 63 | if (IS_ERR(inode)) |
64 | mlog_errno(PTR_ERR(inode)); | ||
65 | return (void *)inode; | 64 | return (void *)inode; |
66 | } | ||
67 | 65 | ||
68 | if (handle->ih_generation != inode->i_generation) { | 66 | if (handle->ih_generation != inode->i_generation) { |
69 | iput(inode); | 67 | iput(inode); |
70 | mlog_errno(-ESTALE); | ||
71 | return ERR_PTR(-ESTALE); | 68 | return ERR_PTR(-ESTALE); |
72 | } | 69 | } |
73 | 70 | ||
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index e4d91493d7d7..28ab56f2b98c 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c | |||
@@ -146,7 +146,6 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags) | |||
146 | if (is_bad_inode(inode)) { | 146 | if (is_bad_inode(inode)) { |
147 | iput(inode); | 147 | iput(inode); |
148 | inode = ERR_PTR(-ESTALE); | 148 | inode = ERR_PTR(-ESTALE); |
149 | mlog_errno(PTR_ERR(inode)); | ||
150 | goto bail; | 149 | goto bail; |
151 | } | 150 | } |
152 | 151 | ||
@@ -155,8 +154,7 @@ bail: | |||
155 | mlog(0, "returning inode with number %llu\n", | 154 | mlog(0, "returning inode with number %llu\n", |
156 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | 155 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
157 | mlog_exit_ptr(inode); | 156 | mlog_exit_ptr(inode); |
158 | } else | 157 | } |
159 | mlog_errno(PTR_ERR(inode)); | ||
160 | 158 | ||
161 | return inode; | 159 | return inode; |
162 | } | 160 | } |
@@ -247,7 +245,7 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, | |||
247 | * today. change if needed. */ | 245 | * today. change if needed. */ |
248 | if (!OCFS2_IS_VALID_DINODE(fe) || | 246 | if (!OCFS2_IS_VALID_DINODE(fe) || |
249 | !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL))) { | 247 | !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL))) { |
250 | mlog(ML_ERROR, "Invalid dinode: i_ino=%lu, i_blkno=%llu, " | 248 | mlog(0, "Invalid dinode: i_ino=%lu, i_blkno=%llu, " |
251 | "signature = %.*s, flags = 0x%x\n", | 249 | "signature = %.*s, flags = 0x%x\n", |
252 | inode->i_ino, | 250 | inode->i_ino, |
253 | (unsigned long long)le64_to_cpu(fe->i_blkno), 7, | 251 | (unsigned long long)le64_to_cpu(fe->i_blkno), 7, |
@@ -478,11 +476,8 @@ static int ocfs2_read_locked_inode(struct inode *inode, | |||
478 | S_ISBLK(le16_to_cpu(fe->i_mode))) | 476 | S_ISBLK(le16_to_cpu(fe->i_mode))) |
479 | inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev)); | 477 | inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev)); |
480 | 478 | ||
481 | if (ocfs2_populate_inode(inode, fe, 0) < 0) { | 479 | if (ocfs2_populate_inode(inode, fe, 0) < 0) |
482 | mlog(ML_ERROR, "populate failed! i_blkno=%llu, i_ino=%lu\n", | ||
483 | (unsigned long long)fe->i_blkno, inode->i_ino); | ||
484 | goto bail; | 480 | goto bail; |
485 | } | ||
486 | 481 | ||
487 | BUG_ON(args->fi_blkno != le64_to_cpu(fe->i_blkno)); | 482 | BUG_ON(args->fi_blkno != le64_to_cpu(fe->i_blkno)); |
488 | 483 | ||
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 9637039c2633..f3d7803b4b46 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -932,14 +932,15 @@ static int ocfs2_unlink(struct inode *dir, | |||
932 | goto leave; | 932 | goto leave; |
933 | } | 933 | } |
934 | 934 | ||
935 | if (S_ISDIR(inode->i_mode)) { | 935 | dir->i_ctime = dir->i_mtime = CURRENT_TIME; |
936 | if (S_ISDIR(inode->i_mode)) | ||
936 | drop_nlink(dir); | 937 | drop_nlink(dir); |
937 | status = ocfs2_mark_inode_dirty(handle, dir, | 938 | |
938 | parent_node_bh); | 939 | status = ocfs2_mark_inode_dirty(handle, dir, parent_node_bh); |
939 | if (status < 0) { | 940 | if (status < 0) { |
940 | mlog_errno(status); | 941 | mlog_errno(status); |
942 | if (S_ISDIR(inode->i_mode)) | ||
941 | inc_nlink(dir); | 943 | inc_nlink(dir); |
942 | } | ||
943 | } | 944 | } |
944 | 945 | ||
945 | leave: | 946 | leave: |
@@ -1068,6 +1069,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1068 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; | 1069 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; |
1069 | struct buffer_head *orphan_entry_bh = NULL; | 1070 | struct buffer_head *orphan_entry_bh = NULL; |
1070 | struct buffer_head *newfe_bh = NULL; | 1071 | struct buffer_head *newfe_bh = NULL; |
1072 | struct buffer_head *old_inode_bh = NULL; | ||
1071 | struct buffer_head *insert_entry_bh = NULL; | 1073 | struct buffer_head *insert_entry_bh = NULL; |
1072 | struct ocfs2_super *osb = NULL; | 1074 | struct ocfs2_super *osb = NULL; |
1073 | u64 newfe_blkno; | 1075 | u64 newfe_blkno; |
@@ -1079,7 +1081,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1079 | struct buffer_head *new_de_bh = NULL, *old_de_bh = NULL; // bhs for above | 1081 | struct buffer_head *new_de_bh = NULL, *old_de_bh = NULL; // bhs for above |
1080 | struct buffer_head *old_inode_de_bh = NULL; // if old_dentry is a dir, | 1082 | struct buffer_head *old_inode_de_bh = NULL; // if old_dentry is a dir, |
1081 | // this is the 1st dirent bh | 1083 | // this is the 1st dirent bh |
1082 | nlink_t old_dir_nlink = old_dir->i_nlink, new_dir_nlink = new_dir->i_nlink; | 1084 | nlink_t old_dir_nlink = old_dir->i_nlink; |
1083 | 1085 | ||
1084 | /* At some point it might be nice to break this function up a | 1086 | /* At some point it might be nice to break this function up a |
1085 | * bit. */ | 1087 | * bit. */ |
@@ -1139,12 +1141,11 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1139 | } | 1141 | } |
1140 | 1142 | ||
1141 | /* | 1143 | /* |
1142 | * Though we don't require an inode meta data update if | 1144 | * Aside from allowing a meta data update, the locking here |
1143 | * old_inode is not a directory, we lock anyway here to ensure | 1145 | * also ensures that the vote thread on other nodes won't have |
1144 | * the vote thread on other nodes won't have to concurrently | 1146 | * to concurrently downconvert the inode and the dentry locks. |
1145 | * downconvert the inode and the dentry locks. | ||
1146 | */ | 1147 | */ |
1147 | status = ocfs2_meta_lock(old_inode, NULL, 1); | 1148 | status = ocfs2_meta_lock(old_inode, &old_inode_bh, 1); |
1148 | if (status < 0) { | 1149 | if (status < 0) { |
1149 | if (status != -ENOENT) | 1150 | if (status != -ENOENT) |
1150 | mlog_errno(status); | 1151 | mlog_errno(status); |
@@ -1355,6 +1356,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1355 | 1356 | ||
1356 | old_inode->i_ctime = CURRENT_TIME; | 1357 | old_inode->i_ctime = CURRENT_TIME; |
1357 | mark_inode_dirty(old_inode); | 1358 | mark_inode_dirty(old_inode); |
1359 | ocfs2_mark_inode_dirty(handle, old_inode, old_inode_bh); | ||
1358 | 1360 | ||
1359 | /* now that the name has been added to new_dir, remove the old name */ | 1361 | /* now that the name has been added to new_dir, remove the old name */ |
1360 | status = ocfs2_delete_entry(handle, old_dir, old_de, old_de_bh); | 1362 | status = ocfs2_delete_entry(handle, old_dir, old_de, old_de_bh); |
@@ -1384,27 +1386,22 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1384 | } | 1386 | } |
1385 | } | 1387 | } |
1386 | mark_inode_dirty(old_dir); | 1388 | mark_inode_dirty(old_dir); |
1387 | if (new_inode) | 1389 | ocfs2_mark_inode_dirty(handle, old_dir, old_dir_bh); |
1390 | if (new_inode) { | ||
1388 | mark_inode_dirty(new_inode); | 1391 | mark_inode_dirty(new_inode); |
1392 | ocfs2_mark_inode_dirty(handle, new_inode, newfe_bh); | ||
1393 | } | ||
1389 | 1394 | ||
1390 | if (old_dir != new_dir) | 1395 | if (old_dir != new_dir) { |
1391 | if (new_dir_nlink != new_dir->i_nlink) { | 1396 | /* Keep the same times on both directories.*/ |
1392 | if (!new_dir_bh) { | 1397 | new_dir->i_ctime = new_dir->i_mtime = old_dir->i_ctime; |
1393 | mlog(ML_ERROR, "need to change nlink for new " | 1398 | |
1394 | "dir %llu from %d to %d but bh is NULL\n", | 1399 | /* |
1395 | (unsigned long long)OCFS2_I(new_dir)->ip_blkno, | 1400 | * This will also pick up the i_nlink change from the |
1396 | (int)new_dir_nlink, new_dir->i_nlink); | 1401 | * block above. |
1397 | } else { | 1402 | */ |
1398 | struct ocfs2_dinode *fe; | 1403 | ocfs2_mark_inode_dirty(handle, new_dir, new_dir_bh); |
1399 | status = ocfs2_journal_access(handle, | 1404 | } |
1400 | new_dir, | ||
1401 | new_dir_bh, | ||
1402 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
1403 | fe = (struct ocfs2_dinode *) new_dir_bh->b_data; | ||
1404 | fe->i_links_count = cpu_to_le16(new_dir->i_nlink); | ||
1405 | status = ocfs2_journal_dirty(handle, new_dir_bh); | ||
1406 | } | ||
1407 | } | ||
1408 | 1405 | ||
1409 | if (old_dir_nlink != old_dir->i_nlink) { | 1406 | if (old_dir_nlink != old_dir->i_nlink) { |
1410 | if (!old_dir_bh) { | 1407 | if (!old_dir_bh) { |
@@ -1455,6 +1452,8 @@ bail: | |||
1455 | iput(new_inode); | 1452 | iput(new_inode); |
1456 | if (newfe_bh) | 1453 | if (newfe_bh) |
1457 | brelse(newfe_bh); | 1454 | brelse(newfe_bh); |
1455 | if (old_inode_bh) | ||
1456 | brelse(old_inode_bh); | ||
1458 | if (old_dir_bh) | 1457 | if (old_dir_bh) |
1459 | brelse(old_dir_bh); | 1458 | brelse(old_dir_bh); |
1460 | if (new_dir_bh) | 1459 | if (new_dir_bh) |
@@ -1826,6 +1825,13 @@ static int __ocfs2_add_entry(handle_t *handle, | |||
1826 | (le16_to_cpu(de->rec_len) >= rec_len)) || | 1825 | (le16_to_cpu(de->rec_len) >= rec_len)) || |
1827 | (le16_to_cpu(de->rec_len) >= | 1826 | (le16_to_cpu(de->rec_len) >= |
1828 | (OCFS2_DIR_REC_LEN(de->name_len) + rec_len))) { | 1827 | (OCFS2_DIR_REC_LEN(de->name_len) + rec_len))) { |
1828 | dir->i_mtime = dir->i_ctime = CURRENT_TIME; | ||
1829 | retval = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh); | ||
1830 | if (retval < 0) { | ||
1831 | mlog_errno(retval); | ||
1832 | goto bail; | ||
1833 | } | ||
1834 | |||
1829 | status = ocfs2_journal_access(handle, dir, insert_bh, | 1835 | status = ocfs2_journal_access(handle, dir, insert_bh, |
1830 | OCFS2_JOURNAL_ACCESS_WRITE); | 1836 | OCFS2_JOURNAL_ACCESS_WRITE); |
1831 | /* By now the buffer is marked for journaling */ | 1837 | /* By now the buffer is marked for journaling */ |
@@ -1848,7 +1854,6 @@ static int __ocfs2_add_entry(handle_t *handle, | |||
1848 | de->name_len = namelen; | 1854 | de->name_len = namelen; |
1849 | memcpy(de->name, name, namelen); | 1855 | memcpy(de->name, name, namelen); |
1850 | 1856 | ||
1851 | dir->i_mtime = dir->i_ctime = CURRENT_TIME; | ||
1852 | dir->i_version++; | 1857 | dir->i_version++; |
1853 | status = ocfs2_journal_dirty(handle, insert_bh); | 1858 | status = ocfs2_journal_dirty(handle, insert_bh); |
1854 | retval = 0; | 1859 | retval = 0; |
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index b5c68567077e..c99e9058c198 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h | |||
@@ -85,7 +85,7 @@ | |||
85 | #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \ | 85 | #define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \ |
86 | OCFS2_SB(sb)->s_feature_incompat &= ~(mask) | 86 | OCFS2_SB(sb)->s_feature_incompat &= ~(mask) |
87 | 87 | ||
88 | #define OCFS2_FEATURE_COMPAT_SUPP 0 | 88 | #define OCFS2_FEATURE_COMPAT_SUPP OCFS2_FEATURE_COMPAT_BACKUP_SB |
89 | #define OCFS2_FEATURE_INCOMPAT_SUPP OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT | 89 | #define OCFS2_FEATURE_INCOMPAT_SUPP OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT |
90 | #define OCFS2_FEATURE_RO_COMPAT_SUPP 0 | 90 | #define OCFS2_FEATURE_RO_COMPAT_SUPP 0 |
91 | 91 | ||
@@ -110,6 +110,20 @@ | |||
110 | #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010 | 110 | #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010 |
111 | 111 | ||
112 | /* | 112 | /* |
113 | * backup superblock flag is used to indicate that this volume | ||
114 | * has backup superblocks. | ||
115 | */ | ||
116 | #define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001 | ||
117 | |||
118 | /* The byte offset of the first backup block will be 1G. | ||
119 | * The following will be 4G, 16G, 64G, 256G and 1T. | ||
120 | */ | ||
121 | #define OCFS2_BACKUP_SB_START 1 << 30 | ||
122 | |||
123 | /* the max backup superblock nums */ | ||
124 | #define OCFS2_MAX_BACKUP_SUPERBLOCKS 6 | ||
125 | |||
126 | /* | ||
113 | * Flags on ocfs2_dinode.i_flags | 127 | * Flags on ocfs2_dinode.i_flags |
114 | */ | 128 | */ |
115 | #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */ | 129 | #define OCFS2_VALID_FL (0x00000001) /* Inode is valid */ |
@@ -566,6 +580,20 @@ static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb) | |||
566 | 580 | ||
567 | return size / sizeof(struct ocfs2_truncate_rec); | 581 | return size / sizeof(struct ocfs2_truncate_rec); |
568 | } | 582 | } |
583 | |||
584 | static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index) | ||
585 | { | ||
586 | u64 offset = OCFS2_BACKUP_SB_START; | ||
587 | |||
588 | if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) { | ||
589 | offset <<= (2 * index); | ||
590 | offset /= sb->s_blocksize; | ||
591 | return offset; | ||
592 | } | ||
593 | |||
594 | return 0; | ||
595 | |||
596 | } | ||
569 | #else | 597 | #else |
570 | static inline int ocfs2_fast_symlink_chars(int blocksize) | 598 | static inline int ocfs2_fast_symlink_chars(int blocksize) |
571 | { | 599 | { |
@@ -631,6 +659,19 @@ static inline int ocfs2_truncate_recs_per_inode(int blocksize) | |||
631 | 659 | ||
632 | return size / sizeof(struct ocfs2_truncate_rec); | 660 | return size / sizeof(struct ocfs2_truncate_rec); |
633 | } | 661 | } |
662 | |||
663 | static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index) | ||
664 | { | ||
665 | uint64_t offset = OCFS2_BACKUP_SB_START; | ||
666 | |||
667 | if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) { | ||
668 | offset <<= (2 * index); | ||
669 | offset /= blocksize; | ||
670 | return offset; | ||
671 | } | ||
672 | |||
673 | return 0; | ||
674 | } | ||
634 | #endif /* __KERNEL__ */ | 675 | #endif /* __KERNEL__ */ |
635 | 676 | ||
636 | 677 | ||
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index 957d6878b03e..03b0191534d5 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c | |||
@@ -158,8 +158,7 @@ static void *ocfs2_follow_link(struct dentry *dentry, | |||
158 | } | 158 | } |
159 | 159 | ||
160 | status = vfs_follow_link(nd, link); | 160 | status = vfs_follow_link(nd, link); |
161 | if (status && status != -ENOENT) | 161 | |
162 | mlog_errno(status); | ||
163 | bail: | 162 | bail: |
164 | if (page) { | 163 | if (page) { |
165 | kunmap(page); | 164 | kunmap(page); |