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

ext3: move headers to fs/ext3/

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 4613ad18 f7699f2b

+437 -668
+1 -7
fs/ext3/acl.c
··· 4 4 * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de> 5 5 */ 6 6 7 - #include <linux/init.h> 8 - #include <linux/sched.h> 9 - #include <linux/slab.h> 10 - #include <linux/capability.h> 11 - #include <linux/fs.h> 12 - #include <linux/ext3_jbd.h> 13 - #include <linux/ext3_fs.h> 7 + #include "ext3.h" 14 8 #include "xattr.h" 15 9 #include "acl.h" 16 10
+1 -9
fs/ext3/balloc.c
··· 11 11 * David S. Miller (davem@caip.rutgers.edu), 1995 12 12 */ 13 13 14 - #include <linux/time.h> 15 - #include <linux/capability.h> 16 - #include <linux/fs.h> 17 - #include <linux/slab.h> 18 - #include <linux/jbd.h> 19 - #include <linux/ext3_fs.h> 20 - #include <linux/ext3_jbd.h> 21 14 #include <linux/quotaops.h> 22 - #include <linux/buffer_head.h> 23 15 #include <linux/blkdev.h> 24 - #include <trace/events/ext3.h> 16 + #include "ext3.h" 25 17 26 18 /* 27 19 * balloc.c contains the blocks allocation and deallocation routines
+1 -3
fs/ext3/bitmap.c
··· 7 7 * Universite Pierre et Marie Curie (Paris VI) 8 8 */ 9 9 10 - #include <linux/buffer_head.h> 11 - #include <linux/jbd.h> 12 - #include <linux/ext3_fs.h> 10 + #include "ext3.h" 13 11 14 12 #ifdef EXT3FS_DEBUG 15 13
+1 -6
fs/ext3/dir.c
··· 21 21 * 22 22 */ 23 23 24 - #include <linux/fs.h> 25 - #include <linux/jbd.h> 26 - #include <linux/ext3_fs.h> 27 - #include <linux/buffer_head.h> 28 - #include <linux/slab.h> 29 - #include <linux/rbtree.h> 24 + #include "ext3.h" 30 25 31 26 static unsigned char ext3_filetype_table[] = { 32 27 DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
+1 -1
fs/ext3/ext3_jbd.c
··· 2 2 * Interface between ext3 and JBD 3 3 */ 4 4 5 - #include <linux/ext3_jbd.h> 5 + #include "ext3.h" 6 6 7 7 int __ext3_journal_get_undo_access(const char *where, handle_t *handle, 8 8 struct buffer_head *bh)
+1 -5
fs/ext3/file.c
··· 18 18 * (jj@sunsite.ms.mff.cuni.cz) 19 19 */ 20 20 21 - #include <linux/time.h> 22 - #include <linux/fs.h> 23 - #include <linux/jbd.h> 24 21 #include <linux/quotaops.h> 25 - #include <linux/ext3_fs.h> 26 - #include <linux/ext3_jbd.h> 22 + #include "ext3.h" 27 23 #include "xattr.h" 28 24 #include "acl.h" 29 25
+1 -7
fs/ext3/fsync.c
··· 22 22 * we can depend on generic_block_fdatasync() to sync the data blocks. 23 23 */ 24 24 25 - #include <linux/time.h> 26 25 #include <linux/blkdev.h> 27 - #include <linux/fs.h> 28 - #include <linux/sched.h> 29 26 #include <linux/writeback.h> 30 - #include <linux/jbd.h> 31 - #include <linux/ext3_fs.h> 32 - #include <linux/ext3_jbd.h> 33 - #include <trace/events/ext3.h> 27 + #include "ext3.h" 34 28 35 29 /* 36 30 * akpm: A new design for ext3_sync_file().
+1 -3
fs/ext3/hash.c
··· 9 9 * License. 10 10 */ 11 11 12 - #include <linux/fs.h> 13 - #include <linux/jbd.h> 14 - #include <linux/ext3_fs.h> 12 + #include "ext3.h" 15 13 #include <linux/cryptohash.h> 16 14 17 15 #define DELTA 0x9E3779B9
+1 -12
fs/ext3/ialloc.c
··· 12 12 * David S. Miller (davem@caip.rutgers.edu), 1995 13 13 */ 14 14 15 - #include <linux/time.h> 16 - #include <linux/fs.h> 17 - #include <linux/jbd.h> 18 - #include <linux/ext3_fs.h> 19 - #include <linux/ext3_jbd.h> 20 - #include <linux/stat.h> 21 - #include <linux/string.h> 22 15 #include <linux/quotaops.h> 23 - #include <linux/buffer_head.h> 24 16 #include <linux/random.h> 25 - #include <linux/bitops.h> 26 - #include <trace/events/ext3.h> 27 17 28 - #include <asm/byteorder.h> 29 - 18 + #include "ext3.h" 30 19 #include "xattr.h" 31 20 #include "acl.h" 32 21
+1 -11
fs/ext3/inode.c
··· 22 22 * Assorted race fixes, rewrite of ext3_get_block() by Al Viro, 2000 23 23 */ 24 24 25 - #include <linux/fs.h> 26 - #include <linux/time.h> 27 - #include <linux/ext3_jbd.h> 28 - #include <linux/jbd.h> 29 25 #include <linux/highuid.h> 30 - #include <linux/pagemap.h> 31 26 #include <linux/quotaops.h> 32 - #include <linux/string.h> 33 - #include <linux/buffer_head.h> 34 27 #include <linux/writeback.h> 35 28 #include <linux/mpage.h> 36 - #include <linux/uio.h> 37 - #include <linux/bio.h> 38 - #include <linux/fiemap.h> 39 29 #include <linux/namei.h> 40 - #include <trace/events/ext3.h> 30 + #include "ext3.h" 41 31 #include "xattr.h" 42 32 #include "acl.h" 43 33
+1 -6
fs/ext3/ioctl.c
··· 7 7 * Universite Pierre et Marie Curie (Paris VI) 8 8 */ 9 9 10 - #include <linux/fs.h> 11 - #include <linux/jbd.h> 12 - #include <linux/capability.h> 13 - #include <linux/ext3_fs.h> 14 - #include <linux/ext3_jbd.h> 15 10 #include <linux/mount.h> 16 - #include <linux/time.h> 17 11 #include <linux/compat.h> 18 12 #include <asm/uaccess.h> 13 + #include "ext3.h" 19 14 20 15 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 21 16 {
+1 -13
fs/ext3/namei.c
··· 24 24 * Theodore Ts'o, 2002 25 25 */ 26 26 27 - #include <linux/fs.h> 28 - #include <linux/pagemap.h> 29 - #include <linux/jbd.h> 30 - #include <linux/time.h> 31 - #include <linux/ext3_fs.h> 32 - #include <linux/ext3_jbd.h> 33 - #include <linux/fcntl.h> 34 - #include <linux/stat.h> 35 - #include <linux/string.h> 36 27 #include <linux/quotaops.h> 37 - #include <linux/buffer_head.h> 38 - #include <linux/bio.h> 39 - #include <trace/events/ext3.h> 40 - 28 + #include "ext3.h" 41 29 #include "namei.h" 42 30 #include "xattr.h" 43 31 #include "acl.h"
+1 -4
fs/ext3/resize.c
··· 11 11 12 12 #define EXT3FS_DEBUG 13 13 14 - #include <linux/ext3_jbd.h> 15 - 16 - #include <linux/errno.h> 17 - #include <linux/slab.h> 14 + #include "ext3.h" 18 15 19 16 20 17 #define outside(b, first, last) ((b) < (first) || (b) >= (last))
+4 -14
fs/ext3/super.c
··· 17 17 */ 18 18 19 19 #include <linux/module.h> 20 - #include <linux/string.h> 21 - #include <linux/fs.h> 22 - #include <linux/time.h> 23 - #include <linux/jbd.h> 24 - #include <linux/ext3_fs.h> 25 - #include <linux/ext3_jbd.h> 26 - #include <linux/slab.h> 27 - #include <linux/init.h> 28 20 #include <linux/blkdev.h> 29 21 #include <linux/parser.h> 30 - #include <linux/buffer_head.h> 31 22 #include <linux/exportfs.h> 32 - #include <linux/vfs.h> 23 + #include <linux/statfs.h> 33 24 #include <linux/random.h> 34 25 #include <linux/mount.h> 35 - #include <linux/namei.h> 36 26 #include <linux/quotaops.h> 37 27 #include <linux/seq_file.h> 38 28 #include <linux/log2.h> ··· 30 40 31 41 #include <asm/uaccess.h> 32 42 43 + #define CREATE_TRACE_POINTS 44 + 45 + #include "ext3.h" 33 46 #include "xattr.h" 34 47 #include "acl.h" 35 48 #include "namei.h" 36 - 37 - #define CREATE_TRACE_POINTS 38 - #include <trace/events/ext3.h> 39 49 40 50 #ifdef CONFIG_EXT3_DEFAULTS_TO_ORDERED 41 51 #define EXT3_MOUNT_DEFAULT_DATA_MODE EXT3_MOUNT_ORDERED_DATA
+1 -3
fs/ext3/symlink.c
··· 17 17 * ext3 symlink handling code 18 18 */ 19 19 20 - #include <linux/fs.h> 21 - #include <linux/jbd.h> 22 - #include <linux/ext3_fs.h> 23 20 #include <linux/namei.h> 21 + #include "ext3.h" 24 22 #include "xattr.h" 25 23 26 24 static void * ext3_follow_link(struct dentry *dentry, struct nameidata *nd)
+1 -6
fs/ext3/xattr.c
··· 50 50 * by the buffer lock. 51 51 */ 52 52 53 - #include <linux/init.h> 54 - #include <linux/fs.h> 55 - #include <linux/slab.h> 56 - #include <linux/ext3_jbd.h> 57 - #include <linux/ext3_fs.h> 53 + #include "ext3.h" 58 54 #include <linux/mbcache.h> 59 55 #include <linux/quotaops.h> 60 - #include <linux/rwsem.h> 61 56 #include "xattr.h" 62 57 #include "acl.h" 63 58
+1 -5
fs/ext3/xattr_security.c
··· 3 3 * Handler for storing security labels as extended attributes. 4 4 */ 5 5 6 - #include <linux/slab.h> 7 - #include <linux/string.h> 8 - #include <linux/fs.h> 9 - #include <linux/ext3_jbd.h> 10 - #include <linux/ext3_fs.h> 11 6 #include <linux/security.h> 7 + #include "ext3.h" 12 8 #include "xattr.h" 13 9 14 10 static size_t
+1 -5
fs/ext3/xattr_trusted.c
··· 5 5 * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org> 6 6 */ 7 7 8 - #include <linux/string.h> 9 - #include <linux/capability.h> 10 - #include <linux/fs.h> 11 - #include <linux/ext3_jbd.h> 12 - #include <linux/ext3_fs.h> 8 + #include "ext3.h" 13 9 #include "xattr.h" 14 10 15 11 static size_t
+1 -4
fs/ext3/xattr_user.c
··· 5 5 * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org> 6 6 */ 7 7 8 - #include <linux/string.h> 9 - #include <linux/fs.h> 10 - #include <linux/ext3_jbd.h> 11 - #include <linux/ext3_fs.h> 8 + #include "ext3.h" 12 9 #include "xattr.h" 13 10 14 11 static size_t
+415 -73
include/linux/ext3_fs.h fs/ext3/ext3.h
··· 1 1 /* 2 - * linux/include/linux/ext3_fs.h 2 + * Written by Stephen C. Tweedie <sct@redhat.com>, 1999 3 + * 4 + * Copyright 1998--1999 Red Hat corp --- All Rights Reserved 5 + * 6 + * This file is part of the Linux kernel and is made available under 7 + * the terms of the GNU General Public License, version 2, or at your 8 + * option, any later version, incorporated herein by reference. 3 9 * 4 10 * Copyright (C) 1992, 1993, 1994, 1995 5 11 * Remy Card (card@masi.ibp.fr) ··· 19 13 * Copyright (C) 1991, 1992 Linus Torvalds 20 14 */ 21 15 22 - #ifndef _LINUX_EXT3_FS_H 23 - #define _LINUX_EXT3_FS_H 24 - 25 - #include <linux/types.h> 16 + #include <linux/fs.h> 17 + #include <linux/jbd.h> 26 18 #include <linux/magic.h> 27 19 #include <linux/bug.h> 20 + #include <linux/blockgroup_lock.h> 28 21 29 22 /* 30 23 * The second extended filesystem constants/structures ··· 80 75 #define EXT3_MIN_BLOCK_SIZE 1024 81 76 #define EXT3_MAX_BLOCK_SIZE 65536 82 77 #define EXT3_MIN_BLOCK_LOG_SIZE 10 83 - #ifdef __KERNEL__ 84 - # define EXT3_BLOCK_SIZE(s) ((s)->s_blocksize) 85 - #else 86 - # define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size) 87 - #endif 78 + #define EXT3_BLOCK_SIZE(s) ((s)->s_blocksize) 88 79 #define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32)) 89 - #ifdef __KERNEL__ 90 - # define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) 91 - #else 92 - # define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) 93 - #endif 94 - #ifdef __KERNEL__ 80 + #define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) 95 81 #define EXT3_ADDR_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_addr_per_block_bits) 96 82 #define EXT3_INODE_SIZE(s) (EXT3_SB(s)->s_inode_size) 97 83 #define EXT3_FIRST_INO(s) (EXT3_SB(s)->s_first_ino) 98 - #else 99 - #define EXT3_INODE_SIZE(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \ 100 - EXT3_GOOD_OLD_INODE_SIZE : \ 101 - (s)->s_inode_size) 102 - #define EXT3_FIRST_INO(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \ 103 - EXT3_GOOD_OLD_FIRST_INO : \ 104 - (s)->s_first_ino) 105 - #endif 106 84 107 85 /* 108 86 * Macro-instructions used to manage fragments ··· 93 105 #define EXT3_MIN_FRAG_SIZE 1024 94 106 #define EXT3_MAX_FRAG_SIZE 4096 95 107 #define EXT3_MIN_FRAG_LOG_SIZE 10 96 - #ifdef __KERNEL__ 97 - # define EXT3_FRAG_SIZE(s) (EXT3_SB(s)->s_frag_size) 98 - # define EXT3_FRAGS_PER_BLOCK(s) (EXT3_SB(s)->s_frags_per_block) 99 - #else 100 - # define EXT3_FRAG_SIZE(s) (EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size) 101 - # define EXT3_FRAGS_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s)) 102 - #endif 108 + #define EXT3_FRAG_SIZE(s) (EXT3_SB(s)->s_frag_size) 109 + #define EXT3_FRAGS_PER_BLOCK(s) (EXT3_SB(s)->s_frags_per_block) 103 110 104 111 /* 105 112 * Structure of a blocks group descriptor ··· 114 131 /* 115 132 * Macro-instructions used to manage group descriptors 116 133 */ 117 - #ifdef __KERNEL__ 118 - # define EXT3_BLOCKS_PER_GROUP(s) (EXT3_SB(s)->s_blocks_per_group) 119 - # define EXT3_DESC_PER_BLOCK(s) (EXT3_SB(s)->s_desc_per_block) 120 - # define EXT3_INODES_PER_GROUP(s) (EXT3_SB(s)->s_inodes_per_group) 121 - # define EXT3_DESC_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_desc_per_block_bits) 122 - #else 123 - # define EXT3_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) 124 - # define EXT3_DESC_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc)) 125 - # define EXT3_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) 126 - #endif 134 + #define EXT3_BLOCKS_PER_GROUP(s) (EXT3_SB(s)->s_blocks_per_group) 135 + #define EXT3_DESC_PER_BLOCK(s) (EXT3_SB(s)->s_desc_per_block) 136 + #define EXT3_INODES_PER_GROUP(s) (EXT3_SB(s)->s_inodes_per_group) 137 + #define EXT3_DESC_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_desc_per_block_bits) 127 138 128 139 /* 129 140 * Constants relative to the data blocks ··· 313 336 314 337 #define i_size_high i_dir_acl 315 338 316 - #if defined(__KERNEL__) || defined(__linux__) 317 339 #define i_reserved1 osd1.linux1.l_i_reserved1 318 340 #define i_frag osd2.linux2.l_i_frag 319 341 #define i_fsize osd2.linux2.l_i_fsize ··· 321 345 #define i_uid_high osd2.linux2.l_i_uid_high 322 346 #define i_gid_high osd2.linux2.l_i_gid_high 323 347 #define i_reserved2 osd2.linux2.l_i_reserved2 324 - 325 - #elif defined(__GNU__) 326 - 327 - #define i_translator osd1.hurd1.h_i_translator 328 - #define i_frag osd2.hurd2.h_i_frag; 329 - #define i_fsize osd2.hurd2.h_i_fsize; 330 - #define i_uid_high osd2.hurd2.h_i_uid_high 331 - #define i_gid_high osd2.hurd2.h_i_gid_high 332 - #define i_author osd2.hurd2.h_i_author 333 - 334 - #elif defined(__masix__) 335 - 336 - #define i_reserved1 osd1.masix1.m_i_reserved1 337 - #define i_frag osd2.masix2.m_i_frag 338 - #define i_fsize osd2.masix2.m_i_fsize 339 - #define i_reserved2 osd2.masix2.m_i_reserved2 340 - 341 - #endif /* defined(__KERNEL__) || defined(__linux__) */ 342 348 343 349 /* 344 350 * File system states ··· 489 531 __u32 s_reserved[162]; /* Padding to the end of the block */ 490 532 }; 491 533 492 - #ifdef __KERNEL__ 493 - #include <linux/ext3_fs_i.h> 494 - #include <linux/ext3_fs_sb.h> 534 + /* data type for block offset of block group */ 535 + typedef int ext3_grpblk_t; 536 + 537 + /* data type for filesystem-wide blocks number */ 538 + typedef unsigned long ext3_fsblk_t; 539 + 540 + #define E3FSBLK "%lu" 541 + 542 + struct ext3_reserve_window { 543 + ext3_fsblk_t _rsv_start; /* First byte reserved */ 544 + ext3_fsblk_t _rsv_end; /* Last byte reserved or 0 */ 545 + }; 546 + 547 + struct ext3_reserve_window_node { 548 + struct rb_node rsv_node; 549 + __u32 rsv_goal_size; 550 + __u32 rsv_alloc_hit; 551 + struct ext3_reserve_window rsv_window; 552 + }; 553 + 554 + struct ext3_block_alloc_info { 555 + /* information about reservation window */ 556 + struct ext3_reserve_window_node rsv_window_node; 557 + /* 558 + * was i_next_alloc_block in ext3_inode_info 559 + * is the logical (file-relative) number of the 560 + * most-recently-allocated block in this file. 561 + * We use this for detecting linearly ascending allocation requests. 562 + */ 563 + __u32 last_alloc_logical_block; 564 + /* 565 + * Was i_next_alloc_goal in ext3_inode_info 566 + * is the *physical* companion to i_next_alloc_block. 567 + * it the physical block number of the block which was most-recentl 568 + * allocated to this file. This give us the goal (target) for the next 569 + * allocation when we detect linearly ascending requests. 570 + */ 571 + ext3_fsblk_t last_alloc_physical_block; 572 + }; 573 + 574 + #define rsv_start rsv_window._rsv_start 575 + #define rsv_end rsv_window._rsv_end 576 + 577 + /* 578 + * third extended file system inode data in memory 579 + */ 580 + struct ext3_inode_info { 581 + __le32 i_data[15]; /* unconverted */ 582 + __u32 i_flags; 583 + #ifdef EXT3_FRAGMENTS 584 + __u32 i_faddr; 585 + __u8 i_frag_no; 586 + __u8 i_frag_size; 587 + #endif 588 + ext3_fsblk_t i_file_acl; 589 + __u32 i_dir_acl; 590 + __u32 i_dtime; 591 + 592 + /* 593 + * i_block_group is the number of the block group which contains 594 + * this file's inode. Constant across the lifetime of the inode, 595 + * it is ued for making block allocation decisions - we try to 596 + * place a file's data blocks near its inode block, and new inodes 597 + * near to their parent directory's inode. 598 + */ 599 + __u32 i_block_group; 600 + unsigned long i_state_flags; /* Dynamic state flags for ext3 */ 601 + 602 + /* block reservation info */ 603 + struct ext3_block_alloc_info *i_block_alloc_info; 604 + 605 + __u32 i_dir_start_lookup; 606 + #ifdef CONFIG_EXT3_FS_XATTR 607 + /* 608 + * Extended attributes can be read independently of the main file 609 + * data. Taking i_mutex even when reading would cause contention 610 + * between readers of EAs and writers of regular file data, so 611 + * instead we synchronize on xattr_sem when reading or changing 612 + * EAs. 613 + */ 614 + struct rw_semaphore xattr_sem; 615 + #endif 616 + 617 + struct list_head i_orphan; /* unlinked but open inodes */ 618 + 619 + /* 620 + * i_disksize keeps track of what the inode size is ON DISK, not 621 + * in memory. During truncate, i_size is set to the new size by 622 + * the VFS prior to calling ext3_truncate(), but the filesystem won't 623 + * set i_disksize to 0 until the truncate is actually under way. 624 + * 625 + * The intent is that i_disksize always represents the blocks which 626 + * are used by this file. This allows recovery to restart truncate 627 + * on orphans if we crash during truncate. We actually write i_disksize 628 + * into the on-disk inode when writing inodes out, instead of i_size. 629 + * 630 + * The only time when i_disksize and i_size may be different is when 631 + * a truncate is in progress. The only things which change i_disksize 632 + * are ext3_get_block (growth) and ext3_truncate (shrinkth). 633 + */ 634 + loff_t i_disksize; 635 + 636 + /* on-disk additional length */ 637 + __u16 i_extra_isize; 638 + 639 + /* 640 + * truncate_mutex is for serialising ext3_truncate() against 641 + * ext3_getblock(). In the 2.4 ext2 design, great chunks of inode's 642 + * data tree are chopped off during truncate. We can't do that in 643 + * ext3 because whenever we perform intermediate commits during 644 + * truncate, the inode and all the metadata blocks *must* be in a 645 + * consistent state which allows truncation of the orphans to restart 646 + * during recovery. Hence we must fix the get_block-vs-truncate race 647 + * by other means, so we have truncate_mutex. 648 + */ 649 + struct mutex truncate_mutex; 650 + 651 + /* 652 + * Transactions that contain inode's metadata needed to complete 653 + * fsync and fdatasync, respectively. 654 + */ 655 + atomic_t i_sync_tid; 656 + atomic_t i_datasync_tid; 657 + 658 + struct inode vfs_inode; 659 + }; 660 + 661 + /* 662 + * third extended-fs super-block data in memory 663 + */ 664 + struct ext3_sb_info { 665 + unsigned long s_frag_size; /* Size of a fragment in bytes */ 666 + unsigned long s_frags_per_block;/* Number of fragments per block */ 667 + unsigned long s_inodes_per_block;/* Number of inodes per block */ 668 + unsigned long s_frags_per_group;/* Number of fragments in a group */ 669 + unsigned long s_blocks_per_group;/* Number of blocks in a group */ 670 + unsigned long s_inodes_per_group;/* Number of inodes in a group */ 671 + unsigned long s_itb_per_group; /* Number of inode table blocks per group */ 672 + unsigned long s_gdb_count; /* Number of group descriptor blocks */ 673 + unsigned long s_desc_per_block; /* Number of group descriptors per block */ 674 + unsigned long s_groups_count; /* Number of groups in the fs */ 675 + unsigned long s_overhead_last; /* Last calculated overhead */ 676 + unsigned long s_blocks_last; /* Last seen block count */ 677 + struct buffer_head * s_sbh; /* Buffer containing the super block */ 678 + struct ext3_super_block * s_es; /* Pointer to the super block in the buffer */ 679 + struct buffer_head ** s_group_desc; 680 + unsigned long s_mount_opt; 681 + ext3_fsblk_t s_sb_block; 682 + uid_t s_resuid; 683 + gid_t s_resgid; 684 + unsigned short s_mount_state; 685 + unsigned short s_pad; 686 + int s_addr_per_block_bits; 687 + int s_desc_per_block_bits; 688 + int s_inode_size; 689 + int s_first_ino; 690 + spinlock_t s_next_gen_lock; 691 + u32 s_next_generation; 692 + u32 s_hash_seed[4]; 693 + int s_def_hash_version; 694 + int s_hash_unsigned; /* 3 if hash should be signed, 0 if not */ 695 + struct percpu_counter s_freeblocks_counter; 696 + struct percpu_counter s_freeinodes_counter; 697 + struct percpu_counter s_dirs_counter; 698 + struct blockgroup_lock *s_blockgroup_lock; 699 + 700 + /* root of the per fs reservation window tree */ 701 + spinlock_t s_rsv_window_lock; 702 + struct rb_root s_rsv_window_root; 703 + struct ext3_reserve_window_node s_rsv_window_head; 704 + 705 + /* Journaling */ 706 + struct inode * s_journal_inode; 707 + struct journal_s * s_journal; 708 + struct list_head s_orphan; 709 + struct mutex s_orphan_lock; 710 + struct mutex s_resize_lock; 711 + unsigned long s_commit_interval; 712 + struct block_device *journal_bdev; 713 + #ifdef CONFIG_QUOTA 714 + char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */ 715 + int s_jquota_fmt; /* Format of quota to use */ 716 + #endif 717 + }; 718 + 719 + static inline spinlock_t * 720 + sb_bgl_lock(struct ext3_sb_info *sbi, unsigned int block_group) 721 + { 722 + return bgl_lock_ptr(sbi->s_blockgroup_lock, block_group); 723 + } 724 + 495 725 static inline struct ext3_sb_info * EXT3_SB(struct super_block *sb) 496 726 { 497 727 return sb->s_fs_info; ··· 722 576 { 723 577 clear_bit(bit, &EXT3_I(inode)->i_state_flags); 724 578 } 725 - #else 726 - /* Assume that user mode programs are passing in an ext3fs superblock, not 727 - * a kernel struct super_block. This will allow us to call the feature-test 728 - * macros from user land. */ 729 - #define EXT3_SB(sb) (sb) 730 - #endif 731 579 732 580 #define NEXT_ORPHAN(inode) EXT3_I(inode)->i_dtime 733 581 ··· 910 770 #define DX_HASH_LEGACY_UNSIGNED 3 911 771 #define DX_HASH_HALF_MD4_UNSIGNED 4 912 772 #define DX_HASH_TEA_UNSIGNED 5 913 - 914 - #ifdef __KERNEL__ 915 773 916 774 /* hash info structure used by the directory hash */ 917 775 struct dx_hash_info ··· 1112 974 extern const struct inode_operations ext3_symlink_inode_operations; 1113 975 extern const struct inode_operations ext3_fast_symlink_inode_operations; 1114 976 977 + #define EXT3_JOURNAL(inode) (EXT3_SB((inode)->i_sb)->s_journal) 1115 978 1116 - #endif /* __KERNEL__ */ 979 + /* Define the number of blocks we need to account to a transaction to 980 + * modify one block of data. 981 + * 982 + * We may have to touch one inode, one bitmap buffer, up to three 983 + * indirection blocks, the group and superblock summaries, and the data 984 + * block to complete the transaction. */ 1117 985 1118 - #endif /* _LINUX_EXT3_FS_H */ 986 + #define EXT3_SINGLEDATA_TRANS_BLOCKS 8U 987 + 988 + /* Extended attribute operations touch at most two data buffers, 989 + * two bitmap buffers, and two group summaries, in addition to the inode 990 + * and the superblock, which are already accounted for. */ 991 + 992 + #define EXT3_XATTR_TRANS_BLOCKS 6U 993 + 994 + /* Define the minimum size for a transaction which modifies data. This 995 + * needs to take into account the fact that we may end up modifying two 996 + * quota files too (one for the group, one for the user quota). The 997 + * superblock only gets updated once, of course, so don't bother 998 + * counting that again for the quota updates. */ 999 + 1000 + #define EXT3_DATA_TRANS_BLOCKS(sb) (EXT3_SINGLEDATA_TRANS_BLOCKS + \ 1001 + EXT3_XATTR_TRANS_BLOCKS - 2 + \ 1002 + EXT3_MAXQUOTAS_TRANS_BLOCKS(sb)) 1003 + 1004 + /* Delete operations potentially hit one directory's namespace plus an 1005 + * entire inode, plus arbitrary amounts of bitmap/indirection data. Be 1006 + * generous. We can grow the delete transaction later if necessary. */ 1007 + 1008 + #define EXT3_DELETE_TRANS_BLOCKS(sb) (EXT3_MAXQUOTAS_TRANS_BLOCKS(sb) + 64) 1009 + 1010 + /* Define an arbitrary limit for the amount of data we will anticipate 1011 + * writing to any given transaction. For unbounded transactions such as 1012 + * write(2) and truncate(2) we can write more than this, but we always 1013 + * start off at the maximum transaction size and grow the transaction 1014 + * optimistically as we go. */ 1015 + 1016 + #define EXT3_MAX_TRANS_DATA 64U 1017 + 1018 + /* We break up a large truncate or write transaction once the handle's 1019 + * buffer credits gets this low, we need either to extend the 1020 + * transaction or to start a new one. Reserve enough space here for 1021 + * inode, bitmap, superblock, group and indirection updates for at least 1022 + * one block, plus two quota updates. Quota allocations are not 1023 + * needed. */ 1024 + 1025 + #define EXT3_RESERVE_TRANS_BLOCKS 12U 1026 + 1027 + #define EXT3_INDEX_EXTRA_TRANS_BLOCKS 8 1028 + 1029 + #ifdef CONFIG_QUOTA 1030 + /* Amount of blocks needed for quota update - we know that the structure was 1031 + * allocated so we need to update only inode+data */ 1032 + #define EXT3_QUOTA_TRANS_BLOCKS(sb) (test_opt(sb, QUOTA) ? 2 : 0) 1033 + /* Amount of blocks needed for quota insert/delete - we do some block writes 1034 + * but inode, sb and group updates are done only once */ 1035 + #define EXT3_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\ 1036 + (EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_INIT_REWRITE) : 0) 1037 + #define EXT3_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\ 1038 + (EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_DEL_REWRITE) : 0) 1039 + #else 1040 + #define EXT3_QUOTA_TRANS_BLOCKS(sb) 0 1041 + #define EXT3_QUOTA_INIT_BLOCKS(sb) 0 1042 + #define EXT3_QUOTA_DEL_BLOCKS(sb) 0 1043 + #endif 1044 + #define EXT3_MAXQUOTAS_TRANS_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_TRANS_BLOCKS(sb)) 1045 + #define EXT3_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_INIT_BLOCKS(sb)) 1046 + #define EXT3_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_DEL_BLOCKS(sb)) 1047 + 1048 + int 1049 + ext3_mark_iloc_dirty(handle_t *handle, 1050 + struct inode *inode, 1051 + struct ext3_iloc *iloc); 1052 + 1053 + /* 1054 + * On success, We end up with an outstanding reference count against 1055 + * iloc->bh. This _must_ be cleaned up later. 1056 + */ 1057 + 1058 + int ext3_reserve_inode_write(handle_t *handle, struct inode *inode, 1059 + struct ext3_iloc *iloc); 1060 + 1061 + int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode); 1062 + 1063 + /* 1064 + * Wrapper functions with which ext3 calls into JBD. The intent here is 1065 + * to allow these to be turned into appropriate stubs so ext3 can control 1066 + * ext2 filesystems, so ext2+ext3 systems only nee one fs. This work hasn't 1067 + * been done yet. 1068 + */ 1069 + 1070 + static inline void ext3_journal_release_buffer(handle_t *handle, 1071 + struct buffer_head *bh) 1072 + { 1073 + journal_release_buffer(handle, bh); 1074 + } 1075 + 1076 + void ext3_journal_abort_handle(const char *caller, const char *err_fn, 1077 + struct buffer_head *bh, handle_t *handle, int err); 1078 + 1079 + int __ext3_journal_get_undo_access(const char *where, handle_t *handle, 1080 + struct buffer_head *bh); 1081 + 1082 + int __ext3_journal_get_write_access(const char *where, handle_t *handle, 1083 + struct buffer_head *bh); 1084 + 1085 + int __ext3_journal_forget(const char *where, handle_t *handle, 1086 + struct buffer_head *bh); 1087 + 1088 + int __ext3_journal_revoke(const char *where, handle_t *handle, 1089 + unsigned long blocknr, struct buffer_head *bh); 1090 + 1091 + int __ext3_journal_get_create_access(const char *where, 1092 + handle_t *handle, struct buffer_head *bh); 1093 + 1094 + int __ext3_journal_dirty_metadata(const char *where, 1095 + handle_t *handle, struct buffer_head *bh); 1096 + 1097 + #define ext3_journal_get_undo_access(handle, bh) \ 1098 + __ext3_journal_get_undo_access(__func__, (handle), (bh)) 1099 + #define ext3_journal_get_write_access(handle, bh) \ 1100 + __ext3_journal_get_write_access(__func__, (handle), (bh)) 1101 + #define ext3_journal_revoke(handle, blocknr, bh) \ 1102 + __ext3_journal_revoke(__func__, (handle), (blocknr), (bh)) 1103 + #define ext3_journal_get_create_access(handle, bh) \ 1104 + __ext3_journal_get_create_access(__func__, (handle), (bh)) 1105 + #define ext3_journal_dirty_metadata(handle, bh) \ 1106 + __ext3_journal_dirty_metadata(__func__, (handle), (bh)) 1107 + #define ext3_journal_forget(handle, bh) \ 1108 + __ext3_journal_forget(__func__, (handle), (bh)) 1109 + 1110 + int ext3_journal_dirty_data(handle_t *handle, struct buffer_head *bh); 1111 + 1112 + handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks); 1113 + int __ext3_journal_stop(const char *where, handle_t *handle); 1114 + 1115 + static inline handle_t *ext3_journal_start(struct inode *inode, int nblocks) 1116 + { 1117 + return ext3_journal_start_sb(inode->i_sb, nblocks); 1118 + } 1119 + 1120 + #define ext3_journal_stop(handle) \ 1121 + __ext3_journal_stop(__func__, (handle)) 1122 + 1123 + static inline handle_t *ext3_journal_current_handle(void) 1124 + { 1125 + return journal_current_handle(); 1126 + } 1127 + 1128 + static inline int ext3_journal_extend(handle_t *handle, int nblocks) 1129 + { 1130 + return journal_extend(handle, nblocks); 1131 + } 1132 + 1133 + static inline int ext3_journal_restart(handle_t *handle, int nblocks) 1134 + { 1135 + return journal_restart(handle, nblocks); 1136 + } 1137 + 1138 + static inline int ext3_journal_blocks_per_page(struct inode *inode) 1139 + { 1140 + return journal_blocks_per_page(inode); 1141 + } 1142 + 1143 + static inline int ext3_journal_force_commit(journal_t *journal) 1144 + { 1145 + return journal_force_commit(journal); 1146 + } 1147 + 1148 + /* super.c */ 1149 + int ext3_force_commit(struct super_block *sb); 1150 + 1151 + static inline int ext3_should_journal_data(struct inode *inode) 1152 + { 1153 + if (!S_ISREG(inode->i_mode)) 1154 + return 1; 1155 + if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA) 1156 + return 1; 1157 + if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL) 1158 + return 1; 1159 + return 0; 1160 + } 1161 + 1162 + static inline int ext3_should_order_data(struct inode *inode) 1163 + { 1164 + if (!S_ISREG(inode->i_mode)) 1165 + return 0; 1166 + if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL) 1167 + return 0; 1168 + if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA) 1169 + return 1; 1170 + return 0; 1171 + } 1172 + 1173 + static inline int ext3_should_writeback_data(struct inode *inode) 1174 + { 1175 + if (!S_ISREG(inode->i_mode)) 1176 + return 0; 1177 + if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL) 1178 + return 0; 1179 + if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) 1180 + return 1; 1181 + return 0; 1182 + } 1183 + 1184 + #include <trace/events/ext3.h>
-151
include/linux/ext3_fs_i.h
··· 1 - /* 2 - * linux/include/linux/ext3_fs_i.h 3 - * 4 - * Copyright (C) 1992, 1993, 1994, 1995 5 - * Remy Card (card@masi.ibp.fr) 6 - * Laboratoire MASI - Institut Blaise Pascal 7 - * Universite Pierre et Marie Curie (Paris VI) 8 - * 9 - * from 10 - * 11 - * linux/include/linux/minix_fs_i.h 12 - * 13 - * Copyright (C) 1991, 1992 Linus Torvalds 14 - */ 15 - 16 - #ifndef _LINUX_EXT3_FS_I 17 - #define _LINUX_EXT3_FS_I 18 - 19 - #include <linux/rwsem.h> 20 - #include <linux/rbtree.h> 21 - #include <linux/seqlock.h> 22 - #include <linux/mutex.h> 23 - 24 - /* data type for block offset of block group */ 25 - typedef int ext3_grpblk_t; 26 - 27 - /* data type for filesystem-wide blocks number */ 28 - typedef unsigned long ext3_fsblk_t; 29 - 30 - #define E3FSBLK "%lu" 31 - 32 - struct ext3_reserve_window { 33 - ext3_fsblk_t _rsv_start; /* First byte reserved */ 34 - ext3_fsblk_t _rsv_end; /* Last byte reserved or 0 */ 35 - }; 36 - 37 - struct ext3_reserve_window_node { 38 - struct rb_node rsv_node; 39 - __u32 rsv_goal_size; 40 - __u32 rsv_alloc_hit; 41 - struct ext3_reserve_window rsv_window; 42 - }; 43 - 44 - struct ext3_block_alloc_info { 45 - /* information about reservation window */ 46 - struct ext3_reserve_window_node rsv_window_node; 47 - /* 48 - * was i_next_alloc_block in ext3_inode_info 49 - * is the logical (file-relative) number of the 50 - * most-recently-allocated block in this file. 51 - * We use this for detecting linearly ascending allocation requests. 52 - */ 53 - __u32 last_alloc_logical_block; 54 - /* 55 - * Was i_next_alloc_goal in ext3_inode_info 56 - * is the *physical* companion to i_next_alloc_block. 57 - * it the physical block number of the block which was most-recentl 58 - * allocated to this file. This give us the goal (target) for the next 59 - * allocation when we detect linearly ascending requests. 60 - */ 61 - ext3_fsblk_t last_alloc_physical_block; 62 - }; 63 - 64 - #define rsv_start rsv_window._rsv_start 65 - #define rsv_end rsv_window._rsv_end 66 - 67 - /* 68 - * third extended file system inode data in memory 69 - */ 70 - struct ext3_inode_info { 71 - __le32 i_data[15]; /* unconverted */ 72 - __u32 i_flags; 73 - #ifdef EXT3_FRAGMENTS 74 - __u32 i_faddr; 75 - __u8 i_frag_no; 76 - __u8 i_frag_size; 77 - #endif 78 - ext3_fsblk_t i_file_acl; 79 - __u32 i_dir_acl; 80 - __u32 i_dtime; 81 - 82 - /* 83 - * i_block_group is the number of the block group which contains 84 - * this file's inode. Constant across the lifetime of the inode, 85 - * it is ued for making block allocation decisions - we try to 86 - * place a file's data blocks near its inode block, and new inodes 87 - * near to their parent directory's inode. 88 - */ 89 - __u32 i_block_group; 90 - unsigned long i_state_flags; /* Dynamic state flags for ext3 */ 91 - 92 - /* block reservation info */ 93 - struct ext3_block_alloc_info *i_block_alloc_info; 94 - 95 - __u32 i_dir_start_lookup; 96 - #ifdef CONFIG_EXT3_FS_XATTR 97 - /* 98 - * Extended attributes can be read independently of the main file 99 - * data. Taking i_mutex even when reading would cause contention 100 - * between readers of EAs and writers of regular file data, so 101 - * instead we synchronize on xattr_sem when reading or changing 102 - * EAs. 103 - */ 104 - struct rw_semaphore xattr_sem; 105 - #endif 106 - 107 - struct list_head i_orphan; /* unlinked but open inodes */ 108 - 109 - /* 110 - * i_disksize keeps track of what the inode size is ON DISK, not 111 - * in memory. During truncate, i_size is set to the new size by 112 - * the VFS prior to calling ext3_truncate(), but the filesystem won't 113 - * set i_disksize to 0 until the truncate is actually under way. 114 - * 115 - * The intent is that i_disksize always represents the blocks which 116 - * are used by this file. This allows recovery to restart truncate 117 - * on orphans if we crash during truncate. We actually write i_disksize 118 - * into the on-disk inode when writing inodes out, instead of i_size. 119 - * 120 - * The only time when i_disksize and i_size may be different is when 121 - * a truncate is in progress. The only things which change i_disksize 122 - * are ext3_get_block (growth) and ext3_truncate (shrinkth). 123 - */ 124 - loff_t i_disksize; 125 - 126 - /* on-disk additional length */ 127 - __u16 i_extra_isize; 128 - 129 - /* 130 - * truncate_mutex is for serialising ext3_truncate() against 131 - * ext3_getblock(). In the 2.4 ext2 design, great chunks of inode's 132 - * data tree are chopped off during truncate. We can't do that in 133 - * ext3 because whenever we perform intermediate commits during 134 - * truncate, the inode and all the metadata blocks *must* be in a 135 - * consistent state which allows truncation of the orphans to restart 136 - * during recovery. Hence we must fix the get_block-vs-truncate race 137 - * by other means, so we have truncate_mutex. 138 - */ 139 - struct mutex truncate_mutex; 140 - 141 - /* 142 - * Transactions that contain inode's metadata needed to complete 143 - * fsync and fdatasync, respectively. 144 - */ 145 - atomic_t i_sync_tid; 146 - atomic_t i_datasync_tid; 147 - 148 - struct inode vfs_inode; 149 - }; 150 - 151 - #endif /* _LINUX_EXT3_FS_I */
-91
include/linux/ext3_fs_sb.h
··· 1 - /* 2 - * linux/include/linux/ext3_fs_sb.h 3 - * 4 - * Copyright (C) 1992, 1993, 1994, 1995 5 - * Remy Card (card@masi.ibp.fr) 6 - * Laboratoire MASI - Institut Blaise Pascal 7 - * Universite Pierre et Marie Curie (Paris VI) 8 - * 9 - * from 10 - * 11 - * linux/include/linux/minix_fs_sb.h 12 - * 13 - * Copyright (C) 1991, 1992 Linus Torvalds 14 - */ 15 - 16 - #ifndef _LINUX_EXT3_FS_SB 17 - #define _LINUX_EXT3_FS_SB 18 - 19 - #ifdef __KERNEL__ 20 - #include <linux/timer.h> 21 - #include <linux/wait.h> 22 - #include <linux/blockgroup_lock.h> 23 - #include <linux/percpu_counter.h> 24 - #endif 25 - #include <linux/rbtree.h> 26 - 27 - /* 28 - * third extended-fs super-block data in memory 29 - */ 30 - struct ext3_sb_info { 31 - unsigned long s_frag_size; /* Size of a fragment in bytes */ 32 - unsigned long s_frags_per_block;/* Number of fragments per block */ 33 - unsigned long s_inodes_per_block;/* Number of inodes per block */ 34 - unsigned long s_frags_per_group;/* Number of fragments in a group */ 35 - unsigned long s_blocks_per_group;/* Number of blocks in a group */ 36 - unsigned long s_inodes_per_group;/* Number of inodes in a group */ 37 - unsigned long s_itb_per_group; /* Number of inode table blocks per group */ 38 - unsigned long s_gdb_count; /* Number of group descriptor blocks */ 39 - unsigned long s_desc_per_block; /* Number of group descriptors per block */ 40 - unsigned long s_groups_count; /* Number of groups in the fs */ 41 - unsigned long s_overhead_last; /* Last calculated overhead */ 42 - unsigned long s_blocks_last; /* Last seen block count */ 43 - struct buffer_head * s_sbh; /* Buffer containing the super block */ 44 - struct ext3_super_block * s_es; /* Pointer to the super block in the buffer */ 45 - struct buffer_head ** s_group_desc; 46 - unsigned long s_mount_opt; 47 - ext3_fsblk_t s_sb_block; 48 - uid_t s_resuid; 49 - gid_t s_resgid; 50 - unsigned short s_mount_state; 51 - unsigned short s_pad; 52 - int s_addr_per_block_bits; 53 - int s_desc_per_block_bits; 54 - int s_inode_size; 55 - int s_first_ino; 56 - spinlock_t s_next_gen_lock; 57 - u32 s_next_generation; 58 - u32 s_hash_seed[4]; 59 - int s_def_hash_version; 60 - int s_hash_unsigned; /* 3 if hash should be signed, 0 if not */ 61 - struct percpu_counter s_freeblocks_counter; 62 - struct percpu_counter s_freeinodes_counter; 63 - struct percpu_counter s_dirs_counter; 64 - struct blockgroup_lock *s_blockgroup_lock; 65 - 66 - /* root of the per fs reservation window tree */ 67 - spinlock_t s_rsv_window_lock; 68 - struct rb_root s_rsv_window_root; 69 - struct ext3_reserve_window_node s_rsv_window_head; 70 - 71 - /* Journaling */ 72 - struct inode * s_journal_inode; 73 - struct journal_s * s_journal; 74 - struct list_head s_orphan; 75 - struct mutex s_orphan_lock; 76 - struct mutex s_resize_lock; 77 - unsigned long s_commit_interval; 78 - struct block_device *journal_bdev; 79 - #ifdef CONFIG_QUOTA 80 - char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */ 81 - int s_jquota_fmt; /* Format of quota to use */ 82 - #endif 83 - }; 84 - 85 - static inline spinlock_t * 86 - sb_bgl_lock(struct ext3_sb_info *sbi, unsigned int block_group) 87 - { 88 - return bgl_lock_ptr(sbi->s_blockgroup_lock, block_group); 89 - } 90 - 91 - #endif /* _LINUX_EXT3_FS_SB */
-229
include/linux/ext3_jbd.h
··· 1 - /* 2 - * linux/include/linux/ext3_jbd.h 3 - * 4 - * Written by Stephen C. Tweedie <sct@redhat.com>, 1999 5 - * 6 - * Copyright 1998--1999 Red Hat corp --- All Rights Reserved 7 - * 8 - * This file is part of the Linux kernel and is made available under 9 - * the terms of the GNU General Public License, version 2, or at your 10 - * option, any later version, incorporated herein by reference. 11 - * 12 - * Ext3-specific journaling extensions. 13 - */ 14 - 15 - #ifndef _LINUX_EXT3_JBD_H 16 - #define _LINUX_EXT3_JBD_H 17 - 18 - #include <linux/fs.h> 19 - #include <linux/jbd.h> 20 - #include <linux/ext3_fs.h> 21 - 22 - #define EXT3_JOURNAL(inode) (EXT3_SB((inode)->i_sb)->s_journal) 23 - 24 - /* Define the number of blocks we need to account to a transaction to 25 - * modify one block of data. 26 - * 27 - * We may have to touch one inode, one bitmap buffer, up to three 28 - * indirection blocks, the group and superblock summaries, and the data 29 - * block to complete the transaction. */ 30 - 31 - #define EXT3_SINGLEDATA_TRANS_BLOCKS 8U 32 - 33 - /* Extended attribute operations touch at most two data buffers, 34 - * two bitmap buffers, and two group summaries, in addition to the inode 35 - * and the superblock, which are already accounted for. */ 36 - 37 - #define EXT3_XATTR_TRANS_BLOCKS 6U 38 - 39 - /* Define the minimum size for a transaction which modifies data. This 40 - * needs to take into account the fact that we may end up modifying two 41 - * quota files too (one for the group, one for the user quota). The 42 - * superblock only gets updated once, of course, so don't bother 43 - * counting that again for the quota updates. */ 44 - 45 - #define EXT3_DATA_TRANS_BLOCKS(sb) (EXT3_SINGLEDATA_TRANS_BLOCKS + \ 46 - EXT3_XATTR_TRANS_BLOCKS - 2 + \ 47 - EXT3_MAXQUOTAS_TRANS_BLOCKS(sb)) 48 - 49 - /* Delete operations potentially hit one directory's namespace plus an 50 - * entire inode, plus arbitrary amounts of bitmap/indirection data. Be 51 - * generous. We can grow the delete transaction later if necessary. */ 52 - 53 - #define EXT3_DELETE_TRANS_BLOCKS(sb) (EXT3_MAXQUOTAS_TRANS_BLOCKS(sb) + 64) 54 - 55 - /* Define an arbitrary limit for the amount of data we will anticipate 56 - * writing to any given transaction. For unbounded transactions such as 57 - * write(2) and truncate(2) we can write more than this, but we always 58 - * start off at the maximum transaction size and grow the transaction 59 - * optimistically as we go. */ 60 - 61 - #define EXT3_MAX_TRANS_DATA 64U 62 - 63 - /* We break up a large truncate or write transaction once the handle's 64 - * buffer credits gets this low, we need either to extend the 65 - * transaction or to start a new one. Reserve enough space here for 66 - * inode, bitmap, superblock, group and indirection updates for at least 67 - * one block, plus two quota updates. Quota allocations are not 68 - * needed. */ 69 - 70 - #define EXT3_RESERVE_TRANS_BLOCKS 12U 71 - 72 - #define EXT3_INDEX_EXTRA_TRANS_BLOCKS 8 73 - 74 - #ifdef CONFIG_QUOTA 75 - /* Amount of blocks needed for quota update - we know that the structure was 76 - * allocated so we need to update only inode+data */ 77 - #define EXT3_QUOTA_TRANS_BLOCKS(sb) (test_opt(sb, QUOTA) ? 2 : 0) 78 - /* Amount of blocks needed for quota insert/delete - we do some block writes 79 - * but inode, sb and group updates are done only once */ 80 - #define EXT3_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\ 81 - (EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_INIT_REWRITE) : 0) 82 - #define EXT3_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\ 83 - (EXT3_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_DEL_REWRITE) : 0) 84 - #else 85 - #define EXT3_QUOTA_TRANS_BLOCKS(sb) 0 86 - #define EXT3_QUOTA_INIT_BLOCKS(sb) 0 87 - #define EXT3_QUOTA_DEL_BLOCKS(sb) 0 88 - #endif 89 - #define EXT3_MAXQUOTAS_TRANS_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_TRANS_BLOCKS(sb)) 90 - #define EXT3_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_INIT_BLOCKS(sb)) 91 - #define EXT3_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_DEL_BLOCKS(sb)) 92 - 93 - int 94 - ext3_mark_iloc_dirty(handle_t *handle, 95 - struct inode *inode, 96 - struct ext3_iloc *iloc); 97 - 98 - /* 99 - * On success, We end up with an outstanding reference count against 100 - * iloc->bh. This _must_ be cleaned up later. 101 - */ 102 - 103 - int ext3_reserve_inode_write(handle_t *handle, struct inode *inode, 104 - struct ext3_iloc *iloc); 105 - 106 - int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode); 107 - 108 - /* 109 - * Wrapper functions with which ext3 calls into JBD. The intent here is 110 - * to allow these to be turned into appropriate stubs so ext3 can control 111 - * ext2 filesystems, so ext2+ext3 systems only nee one fs. This work hasn't 112 - * been done yet. 113 - */ 114 - 115 - static inline void ext3_journal_release_buffer(handle_t *handle, 116 - struct buffer_head *bh) 117 - { 118 - journal_release_buffer(handle, bh); 119 - } 120 - 121 - void ext3_journal_abort_handle(const char *caller, const char *err_fn, 122 - struct buffer_head *bh, handle_t *handle, int err); 123 - 124 - int __ext3_journal_get_undo_access(const char *where, handle_t *handle, 125 - struct buffer_head *bh); 126 - 127 - int __ext3_journal_get_write_access(const char *where, handle_t *handle, 128 - struct buffer_head *bh); 129 - 130 - int __ext3_journal_forget(const char *where, handle_t *handle, 131 - struct buffer_head *bh); 132 - 133 - int __ext3_journal_revoke(const char *where, handle_t *handle, 134 - unsigned long blocknr, struct buffer_head *bh); 135 - 136 - int __ext3_journal_get_create_access(const char *where, 137 - handle_t *handle, struct buffer_head *bh); 138 - 139 - int __ext3_journal_dirty_metadata(const char *where, 140 - handle_t *handle, struct buffer_head *bh); 141 - 142 - #define ext3_journal_get_undo_access(handle, bh) \ 143 - __ext3_journal_get_undo_access(__func__, (handle), (bh)) 144 - #define ext3_journal_get_write_access(handle, bh) \ 145 - __ext3_journal_get_write_access(__func__, (handle), (bh)) 146 - #define ext3_journal_revoke(handle, blocknr, bh) \ 147 - __ext3_journal_revoke(__func__, (handle), (blocknr), (bh)) 148 - #define ext3_journal_get_create_access(handle, bh) \ 149 - __ext3_journal_get_create_access(__func__, (handle), (bh)) 150 - #define ext3_journal_dirty_metadata(handle, bh) \ 151 - __ext3_journal_dirty_metadata(__func__, (handle), (bh)) 152 - #define ext3_journal_forget(handle, bh) \ 153 - __ext3_journal_forget(__func__, (handle), (bh)) 154 - 155 - int ext3_journal_dirty_data(handle_t *handle, struct buffer_head *bh); 156 - 157 - handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks); 158 - int __ext3_journal_stop(const char *where, handle_t *handle); 159 - 160 - static inline handle_t *ext3_journal_start(struct inode *inode, int nblocks) 161 - { 162 - return ext3_journal_start_sb(inode->i_sb, nblocks); 163 - } 164 - 165 - #define ext3_journal_stop(handle) \ 166 - __ext3_journal_stop(__func__, (handle)) 167 - 168 - static inline handle_t *ext3_journal_current_handle(void) 169 - { 170 - return journal_current_handle(); 171 - } 172 - 173 - static inline int ext3_journal_extend(handle_t *handle, int nblocks) 174 - { 175 - return journal_extend(handle, nblocks); 176 - } 177 - 178 - static inline int ext3_journal_restart(handle_t *handle, int nblocks) 179 - { 180 - return journal_restart(handle, nblocks); 181 - } 182 - 183 - static inline int ext3_journal_blocks_per_page(struct inode *inode) 184 - { 185 - return journal_blocks_per_page(inode); 186 - } 187 - 188 - static inline int ext3_journal_force_commit(journal_t *journal) 189 - { 190 - return journal_force_commit(journal); 191 - } 192 - 193 - /* super.c */ 194 - int ext3_force_commit(struct super_block *sb); 195 - 196 - static inline int ext3_should_journal_data(struct inode *inode) 197 - { 198 - if (!S_ISREG(inode->i_mode)) 199 - return 1; 200 - if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA) 201 - return 1; 202 - if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL) 203 - return 1; 204 - return 0; 205 - } 206 - 207 - static inline int ext3_should_order_data(struct inode *inode) 208 - { 209 - if (!S_ISREG(inode->i_mode)) 210 - return 0; 211 - if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL) 212 - return 0; 213 - if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA) 214 - return 1; 215 - return 0; 216 - } 217 - 218 - static inline int ext3_should_writeback_data(struct inode *inode) 219 - { 220 - if (!S_ISREG(inode->i_mode)) 221 - return 0; 222 - if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL) 223 - return 0; 224 - if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) 225 - return 1; 226 - return 0; 227 - } 228 - 229 - #endif /* _LINUX_EXT3_JBD_H */