diff options
Diffstat (limited to 'fs/ocfs2/journal.h')
| -rw-r--r-- | fs/ocfs2/journal.h | 128 |
1 files changed, 98 insertions, 30 deletions
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h index d4d14e9a3cea..3c3532e1307c 100644 --- a/fs/ocfs2/journal.h +++ b/fs/ocfs2/journal.h | |||
| @@ -27,12 +27,7 @@ | |||
| 27 | #define OCFS2_JOURNAL_H | 27 | #define OCFS2_JOURNAL_H |
| 28 | 28 | ||
| 29 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
| 30 | #ifndef CONFIG_OCFS2_COMPAT_JBD | 30 | #include <linux/jbd2.h> |
| 31 | # include <linux/jbd2.h> | ||
| 32 | #else | ||
| 33 | # include <linux/jbd.h> | ||
| 34 | # include "ocfs2_jbd_compat.h" | ||
| 35 | #endif | ||
| 36 | 31 | ||
| 37 | enum ocfs2_journal_state { | 32 | enum ocfs2_journal_state { |
| 38 | OCFS2_JOURNAL_FREE = 0, | 33 | OCFS2_JOURNAL_FREE = 0, |
| @@ -173,6 +168,7 @@ void ocfs2_recovery_thread(struct ocfs2_super *osb, | |||
| 173 | int node_num); | 168 | int node_num); |
| 174 | int ocfs2_mark_dead_nodes(struct ocfs2_super *osb); | 169 | int ocfs2_mark_dead_nodes(struct ocfs2_super *osb); |
| 175 | void ocfs2_complete_mount_recovery(struct ocfs2_super *osb); | 170 | void ocfs2_complete_mount_recovery(struct ocfs2_super *osb); |
| 171 | void ocfs2_complete_quota_recovery(struct ocfs2_super *osb); | ||
| 176 | 172 | ||
| 177 | static inline void ocfs2_start_checkpoint(struct ocfs2_super *osb) | 173 | static inline void ocfs2_start_checkpoint(struct ocfs2_super *osb) |
| 178 | { | 174 | { |
| @@ -216,9 +212,12 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode) | |||
| 216 | * ocfs2_extend_trans - Extend a handle by nblocks credits. This may | 212 | * ocfs2_extend_trans - Extend a handle by nblocks credits. This may |
| 217 | * commit the handle to disk in the process, but will | 213 | * commit the handle to disk in the process, but will |
| 218 | * not release any locks taken during the transaction. | 214 | * not release any locks taken during the transaction. |
| 219 | * ocfs2_journal_access - Notify the handle that we want to journal this | 215 | * ocfs2_journal_access* - Notify the handle that we want to journal this |
| 220 | * buffer. Will have to call ocfs2_journal_dirty once | 216 | * buffer. Will have to call ocfs2_journal_dirty once |
| 221 | * we've actually dirtied it. Type is one of . or . | 217 | * we've actually dirtied it. Type is one of . or . |
| 218 | * Always call the specific flavor of | ||
| 219 | * ocfs2_journal_access_*() unless you intend to | ||
| 220 | * manage the checksum by hand. | ||
| 222 | * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. | 221 | * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. |
| 223 | * ocfs2_jbd2_file_inode - Mark an inode so that its data goes out before | 222 | * ocfs2_jbd2_file_inode - Mark an inode so that its data goes out before |
| 224 | * the current handle commits. | 223 | * the current handle commits. |
| @@ -248,10 +247,29 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks); | |||
| 248 | #define OCFS2_JOURNAL_ACCESS_WRITE 1 | 247 | #define OCFS2_JOURNAL_ACCESS_WRITE 1 |
| 249 | #define OCFS2_JOURNAL_ACCESS_UNDO 2 | 248 | #define OCFS2_JOURNAL_ACCESS_UNDO 2 |
| 250 | 249 | ||
| 251 | int ocfs2_journal_access(handle_t *handle, | 250 | |
| 252 | struct inode *inode, | 251 | /* ocfs2_inode */ |
| 253 | struct buffer_head *bh, | 252 | int ocfs2_journal_access_di(handle_t *handle, struct inode *inode, |
| 254 | int type); | 253 | struct buffer_head *bh, int type); |
| 254 | /* ocfs2_extent_block */ | ||
| 255 | int ocfs2_journal_access_eb(handle_t *handle, struct inode *inode, | ||
| 256 | struct buffer_head *bh, int type); | ||
| 257 | /* ocfs2_group_desc */ | ||
| 258 | int ocfs2_journal_access_gd(handle_t *handle, struct inode *inode, | ||
| 259 | struct buffer_head *bh, int type); | ||
| 260 | /* ocfs2_xattr_block */ | ||
| 261 | int ocfs2_journal_access_xb(handle_t *handle, struct inode *inode, | ||
| 262 | struct buffer_head *bh, int type); | ||
| 263 | /* quota blocks */ | ||
| 264 | int ocfs2_journal_access_dq(handle_t *handle, struct inode *inode, | ||
| 265 | struct buffer_head *bh, int type); | ||
| 266 | /* dirblock */ | ||
| 267 | int ocfs2_journal_access_db(handle_t *handle, struct inode *inode, | ||
| 268 | struct buffer_head *bh, int type); | ||
| 269 | /* Anything that has no ecc */ | ||
| 270 | int ocfs2_journal_access(handle_t *handle, struct inode *inode, | ||
| 271 | struct buffer_head *bh, int type); | ||
| 272 | |||
| 255 | /* | 273 | /* |
| 256 | * A word about the journal_access/journal_dirty "dance". It is | 274 | * A word about the journal_access/journal_dirty "dance". It is |
| 257 | * entirely legal to journal_access a buffer more than once (as long | 275 | * entirely legal to journal_access a buffer more than once (as long |
| @@ -273,10 +291,6 @@ int ocfs2_journal_access(handle_t *handle, | |||
| 273 | */ | 291 | */ |
| 274 | int ocfs2_journal_dirty(handle_t *handle, | 292 | int ocfs2_journal_dirty(handle_t *handle, |
| 275 | struct buffer_head *bh); | 293 | struct buffer_head *bh); |
| 276 | #ifdef CONFIG_OCFS2_COMPAT_JBD | ||
| 277 | int ocfs2_journal_dirty_data(handle_t *handle, | ||
| 278 | struct buffer_head *bh); | ||
| 279 | #endif | ||
| 280 | 294 | ||
| 281 | /* | 295 | /* |
| 282 | * Credit Macros: | 296 | * Credit Macros: |
| @@ -293,6 +307,37 @@ int ocfs2_journal_dirty_data(handle_t *handle, | |||
| 293 | /* extended attribute block update */ | 307 | /* extended attribute block update */ |
| 294 | #define OCFS2_XATTR_BLOCK_UPDATE_CREDITS 1 | 308 | #define OCFS2_XATTR_BLOCK_UPDATE_CREDITS 1 |
| 295 | 309 | ||
| 310 | /* global quotafile inode update, data block */ | ||
| 311 | #define OCFS2_QINFO_WRITE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1) | ||
| 312 | |||
| 313 | /* | ||
| 314 | * The two writes below can accidentally see global info dirty due | ||
| 315 | * to set_info() quotactl so make them prepared for the writes. | ||
| 316 | */ | ||
| 317 | /* quota data block, global info */ | ||
| 318 | /* Write to local quota file */ | ||
| 319 | #define OCFS2_QWRITE_CREDITS (OCFS2_QINFO_WRITE_CREDITS + 1) | ||
| 320 | |||
| 321 | /* global quota data block, local quota data block, global quota inode, | ||
| 322 | * global quota info */ | ||
| 323 | #define OCFS2_QSYNC_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 3) | ||
| 324 | |||
| 325 | static inline int ocfs2_quota_trans_credits(struct super_block *sb) | ||
| 326 | { | ||
| 327 | int credits = 0; | ||
| 328 | |||
| 329 | if (OCFS2_HAS_RO_COMPAT_FEATURE(sb, OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) | ||
| 330 | credits += OCFS2_QWRITE_CREDITS; | ||
| 331 | if (OCFS2_HAS_RO_COMPAT_FEATURE(sb, OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) | ||
| 332 | credits += OCFS2_QWRITE_CREDITS; | ||
| 333 | return credits; | ||
| 334 | } | ||
| 335 | |||
| 336 | /* Number of credits needed for removing quota structure from file */ | ||
| 337 | int ocfs2_calc_qdel_credits(struct super_block *sb, int type); | ||
| 338 | /* Number of credits needed for initialization of new quota structure */ | ||
| 339 | int ocfs2_calc_qinit_credits(struct super_block *sb, int type); | ||
| 340 | |||
| 296 | /* group extend. inode update and last group update. */ | 341 | /* group extend. inode update and last group update. */ |
| 297 | #define OCFS2_GROUP_EXTEND_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1) | 342 | #define OCFS2_GROUP_EXTEND_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1) |
| 298 | 343 | ||
| @@ -303,8 +348,11 @@ int ocfs2_journal_dirty_data(handle_t *handle, | |||
| 303 | * prev. group desc. if we relink. */ | 348 | * prev. group desc. if we relink. */ |
| 304 | #define OCFS2_SUBALLOC_ALLOC (3) | 349 | #define OCFS2_SUBALLOC_ALLOC (3) |
| 305 | 350 | ||
| 306 | #define OCFS2_INLINE_TO_EXTENTS_CREDITS (OCFS2_SUBALLOC_ALLOC \ | 351 | static inline int ocfs2_inline_to_extents_credits(struct super_block *sb) |
| 307 | + OCFS2_INODE_UPDATE_CREDITS) | 352 | { |
| 353 | return OCFS2_SUBALLOC_ALLOC + OCFS2_INODE_UPDATE_CREDITS + | ||
| 354 | ocfs2_quota_trans_credits(sb); | ||
| 355 | } | ||
| 308 | 356 | ||
| 309 | /* dinode + group descriptor update. We don't relink on free yet. */ | 357 | /* dinode + group descriptor update. We don't relink on free yet. */ |
| 310 | #define OCFS2_SUBALLOC_FREE (2) | 358 | #define OCFS2_SUBALLOC_FREE (2) |
| @@ -313,16 +361,23 @@ int ocfs2_journal_dirty_data(handle_t *handle, | |||
| 313 | #define OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC (OCFS2_SUBALLOC_FREE \ | 361 | #define OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC (OCFS2_SUBALLOC_FREE \ |
| 314 | + OCFS2_TRUNCATE_LOG_UPDATE) | 362 | + OCFS2_TRUNCATE_LOG_UPDATE) |
| 315 | 363 | ||
| 316 | #define OCFS2_REMOVE_EXTENT_CREDITS (OCFS2_TRUNCATE_LOG_UPDATE + OCFS2_INODE_UPDATE_CREDITS) | 364 | static inline int ocfs2_remove_extent_credits(struct super_block *sb) |
| 365 | { | ||
| 366 | return OCFS2_TRUNCATE_LOG_UPDATE + OCFS2_INODE_UPDATE_CREDITS + | ||
| 367 | ocfs2_quota_trans_credits(sb); | ||
| 368 | } | ||
| 317 | 369 | ||
| 318 | /* data block for new dir/symlink, 2 for bitmap updates (bitmap fe + | 370 | /* data block for new dir/symlink, 2 for bitmap updates (bitmap fe + |
| 319 | * bitmap block for the new bit) */ | 371 | * bitmap block for the new bit) */ |
| 320 | #define OCFS2_DIR_LINK_ADDITIONAL_CREDITS (1 + 2) | 372 | #define OCFS2_DIR_LINK_ADDITIONAL_CREDITS (1 + 2) |
| 321 | 373 | ||
| 322 | /* parent fe, parent block, new file entry, inode alloc fe, inode alloc | 374 | /* parent fe, parent block, new file entry, inode alloc fe, inode alloc |
| 323 | * group descriptor + mkdir/symlink blocks */ | 375 | * group descriptor + mkdir/symlink blocks + quota update */ |
| 324 | #define OCFS2_MKNOD_CREDITS (3 + OCFS2_SUBALLOC_ALLOC \ | 376 | static inline int ocfs2_mknod_credits(struct super_block *sb) |
| 325 | + OCFS2_DIR_LINK_ADDITIONAL_CREDITS) | 377 | { |
| 378 | return 3 + OCFS2_SUBALLOC_ALLOC + OCFS2_DIR_LINK_ADDITIONAL_CREDITS + | ||
| 379 | ocfs2_quota_trans_credits(sb); | ||
| 380 | } | ||
| 326 | 381 | ||
| 327 | /* local alloc metadata change + main bitmap updates */ | 382 | /* local alloc metadata change + main bitmap updates */ |
| 328 | #define OCFS2_WINDOW_MOVE_CREDITS (OCFS2_INODE_UPDATE_CREDITS \ | 383 | #define OCFS2_WINDOW_MOVE_CREDITS (OCFS2_INODE_UPDATE_CREDITS \ |
| @@ -332,13 +387,21 @@ int ocfs2_journal_dirty_data(handle_t *handle, | |||
| 332 | * for the dinode, one for the new block. */ | 387 | * for the dinode, one for the new block. */ |
| 333 | #define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2) | 388 | #define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2) |
| 334 | 389 | ||
| 335 | /* file update (nlink, etc) + directory mtime/ctime + dir entry block */ | 390 | /* file update (nlink, etc) + directory mtime/ctime + dir entry block + quota |
| 336 | #define OCFS2_LINK_CREDITS (2*OCFS2_INODE_UPDATE_CREDITS + 1) | 391 | * update on dir */ |
| 392 | static inline int ocfs2_link_credits(struct super_block *sb) | ||
| 393 | { | ||
| 394 | return 2*OCFS2_INODE_UPDATE_CREDITS + 1 + | ||
| 395 | ocfs2_quota_trans_credits(sb); | ||
| 396 | } | ||
| 337 | 397 | ||
| 338 | /* inode + dir inode (if we unlink a dir), + dir entry block + orphan | 398 | /* inode + dir inode (if we unlink a dir), + dir entry block + orphan |
| 339 | * dir inode link */ | 399 | * dir inode link */ |
| 340 | #define OCFS2_UNLINK_CREDITS (2 * OCFS2_INODE_UPDATE_CREDITS + 1 \ | 400 | static inline int ocfs2_unlink_credits(struct super_block *sb) |
| 341 | + OCFS2_LINK_CREDITS) | 401 | { |
| 402 | /* The quota update from ocfs2_link_credits is unused here... */ | ||
| 403 | return 2 * OCFS2_INODE_UPDATE_CREDITS + 1 + ocfs2_link_credits(sb); | ||
| 404 | } | ||
| 342 | 405 | ||
| 343 | /* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry + | 406 | /* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry + |
| 344 | * inode alloc group descriptor */ | 407 | * inode alloc group descriptor */ |
| @@ -347,8 +410,10 @@ int ocfs2_journal_dirty_data(handle_t *handle, | |||
| 347 | /* dinode update, old dir dinode update, new dir dinode update, old | 410 | /* dinode update, old dir dinode update, new dir dinode update, old |
| 348 | * dir dir entry, new dir dir entry, dir entry update for renaming | 411 | * dir dir entry, new dir dir entry, dir entry update for renaming |
| 349 | * directory + target unlink */ | 412 | * directory + target unlink */ |
| 350 | #define OCFS2_RENAME_CREDITS (3 * OCFS2_INODE_UPDATE_CREDITS + 3 \ | 413 | static inline int ocfs2_rename_credits(struct super_block *sb) |
| 351 | + OCFS2_UNLINK_CREDITS) | 414 | { |
| 415 | return 3 * OCFS2_INODE_UPDATE_CREDITS + 3 + ocfs2_unlink_credits(sb); | ||
| 416 | } | ||
| 352 | 417 | ||
| 353 | /* global bitmap dinode, group desc., relinked group, | 418 | /* global bitmap dinode, group desc., relinked group, |
| 354 | * suballocator dinode, group desc., relinked group, | 419 | * suballocator dinode, group desc., relinked group, |
| @@ -386,18 +451,19 @@ static inline int ocfs2_calc_extend_credits(struct super_block *sb, | |||
| 386 | * credit for the dinode there. */ | 451 | * credit for the dinode there. */ |
| 387 | extent_blocks = 1 + 1 + le16_to_cpu(root_el->l_tree_depth); | 452 | extent_blocks = 1 + 1 + le16_to_cpu(root_el->l_tree_depth); |
| 388 | 453 | ||
| 389 | return bitmap_blocks + sysfile_bitmap_blocks + extent_blocks; | 454 | return bitmap_blocks + sysfile_bitmap_blocks + extent_blocks + |
| 455 | ocfs2_quota_trans_credits(sb); | ||
| 390 | } | 456 | } |
| 391 | 457 | ||
| 392 | static inline int ocfs2_calc_symlink_credits(struct super_block *sb) | 458 | static inline int ocfs2_calc_symlink_credits(struct super_block *sb) |
| 393 | { | 459 | { |
| 394 | int blocks = OCFS2_MKNOD_CREDITS; | 460 | int blocks = ocfs2_mknod_credits(sb); |
| 395 | 461 | ||
| 396 | /* links can be longer than one block so we may update many | 462 | /* links can be longer than one block so we may update many |
| 397 | * within our single allocated extent. */ | 463 | * within our single allocated extent. */ |
| 398 | blocks += ocfs2_clusters_to_blocks(sb, 1); | 464 | blocks += ocfs2_clusters_to_blocks(sb, 1); |
| 399 | 465 | ||
| 400 | return blocks; | 466 | return blocks + ocfs2_quota_trans_credits(sb); |
| 401 | } | 467 | } |
| 402 | 468 | ||
| 403 | static inline int ocfs2_calc_group_alloc_credits(struct super_block *sb, | 469 | static inline int ocfs2_calc_group_alloc_credits(struct super_block *sb, |
| @@ -434,6 +500,8 @@ static inline int ocfs2_calc_tree_trunc_credits(struct super_block *sb, | |||
| 434 | /* update to the truncate log. */ | 500 | /* update to the truncate log. */ |
| 435 | credits += OCFS2_TRUNCATE_LOG_UPDATE; | 501 | credits += OCFS2_TRUNCATE_LOG_UPDATE; |
| 436 | 502 | ||
| 503 | credits += ocfs2_quota_trans_credits(sb); | ||
| 504 | |||
| 437 | return credits; | 505 | return credits; |
| 438 | } | 506 | } |
| 439 | 507 | ||
