fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / linux / ext3_fs.h
index ab9c037..ebbe50a 100644 (file)
 #define _LINUX_EXT3_FS_H
 
 #include <linux/types.h>
-#include <linux/ext3_fs_i.h>
-#include <linux/ext3_fs_sb.h>
-
-
-struct statfs;
+#include <linux/magic.h>
 
 /*
  * The second extended filesystem constants/structures
@@ -33,11 +29,12 @@ struct statfs;
 #undef EXT3FS_DEBUG
 
 /*
- * Define EXT3_PREALLOCATE to preallocate data blocks for expanding files
+ * Define EXT3_RESERVATION to reserve data blocks for expanding files
  */
-#undef  EXT3_PREALLOCATE /* @@@ Fix this! */
-#define EXT3_DEFAULT_PREALLOC_BLOCKS   8
-
+#define EXT3_DEFAULT_RESERVE_BLOCKS     8
+/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */
+#define EXT3_MAX_RESERVE_BLOCKS         1027
+#define EXT3_RESERVE_WINDOW_NOT_ALLOCATED 0
 /*
  * Always enable hashed directories
  */
@@ -70,11 +67,6 @@ struct statfs;
 /* First non-reserved inode for old ext3 filesystems */
 #define EXT3_GOOD_OLD_FIRST_INO        11
 
-/*
- * The second extended file system magic number
- */
-#define EXT3_SUPER_MAGIC       0xEF53
-
 /*
  * Maximal count of links to a file
  */
@@ -196,28 +188,88 @@ struct ext3_group_desc
 #define EXT3_FL_USER_VISIBLE           0x0003DFFF /* User visible flags */
 #define EXT3_FL_USER_MODIFIABLE                0x000380FF /* User modifiable flags */
 #endif
+#ifdef CONFIG_VSERVER_LEGACY
+#define EXT3_IOC_SETTAG                        FIOC_SETTAGJ
+#endif
 
 /*
  * Inode dynamic state flags
  */
 #define EXT3_STATE_JDATA               0x00000001 /* journaled data exists */
 #define EXT3_STATE_NEW                 0x00000002 /* inode is newly created */
+#define EXT3_STATE_XATTR               0x00000004 /* has in-inode xattrs */
+
+/* Used to pass group descriptor data when online resize is done */
+struct ext3_new_group_input {
+       __u32 group;            /* Group number for this data */
+       __u32 block_bitmap;     /* Absolute block number of block bitmap */
+       __u32 inode_bitmap;     /* Absolute block number of inode bitmap */
+       __u32 inode_table;      /* Absolute block number of inode table start */
+       __u32 blocks_count;     /* Total number of blocks in this group */
+       __u16 reserved_blocks;  /* Number of reserved blocks in this group */
+       __u16 unused;
+};
+
+/* The struct ext3_new_group_input in kernel space, with free_blocks_count */
+struct ext3_new_group_data {
+       __u32 group;
+       __u32 block_bitmap;
+       __u32 inode_bitmap;
+       __u32 inode_table;
+       __u32 blocks_count;
+       __u16 reserved_blocks;
+       __u16 unused;
+       __u32 free_blocks_count;
+};
+
 
 /*
  * ioctl commands
  */
-#define        EXT3_IOC_GETFLAGS               _IOR('f', 1, long)
-#define        EXT3_IOC_SETFLAGS               _IOW('f', 2, long)
+#define        EXT3_IOC_GETFLAGS               FS_IOC_GETFLAGS
+#define        EXT3_IOC_SETFLAGS               FS_IOC_SETFLAGS
 #define        EXT3_IOC_GETVERSION             _IOR('f', 3, long)
 #define        EXT3_IOC_SETVERSION             _IOW('f', 4, long)
-#define        EXT3_IOC_GETVERSION_OLD         _IOR('v', 1, long)
-#define        EXT3_IOC_SETVERSION_OLD         _IOW('v', 2, long)
+#define EXT3_IOC_GROUP_EXTEND          _IOW('f', 7, unsigned long)
+#define EXT3_IOC_GROUP_ADD             _IOW('f', 8,struct ext3_new_group_input)
+#define        EXT3_IOC_GETVERSION_OLD         FS_IOC_GETVERSION
+#define        EXT3_IOC_SETVERSION_OLD         FS_IOC_SETVERSION
 #ifdef CONFIG_JBD_DEBUG
 #define EXT3_IOC_WAIT_FOR_READONLY     _IOR('f', 99, long)
 #endif
-#ifdef CONFIG_VSERVER_LEGACY
-#define EXT3_IOC_SETXID                        FIOC_SETXIDJ
+#define EXT3_IOC_GETRSVSZ              _IOR('f', 5, long)
+#define EXT3_IOC_SETRSVSZ              _IOW('f', 6, long)
+
+/*
+ * ioctl commands in 32 bit emulation
+ */
+#define EXT3_IOC32_GETFLAGS            FS_IOC32_GETFLAGS
+#define EXT3_IOC32_SETFLAGS            FS_IOC32_SETFLAGS
+#define EXT3_IOC32_GETVERSION          _IOR('f', 3, int)
+#define EXT3_IOC32_SETVERSION          _IOW('f', 4, int)
+#define EXT3_IOC32_GETRSVSZ            _IOR('f', 5, int)
+#define EXT3_IOC32_SETRSVSZ            _IOW('f', 6, int)
+#define EXT3_IOC32_GROUP_EXTEND                _IOW('f', 7, unsigned int)
+#ifdef CONFIG_JBD_DEBUG
+#define EXT3_IOC32_WAIT_FOR_READONLY   _IOR('f', 99, int)
 #endif
+#define EXT3_IOC32_GETVERSION_OLD      FS_IOC32_GETVERSION
+#define EXT3_IOC32_SETVERSION_OLD      FS_IOC32_SETVERSION
+
+
+/*
+ *  Mount options
+ */
+struct ext3_mount_options {
+       unsigned long s_mount_opt;
+       uid_t s_resuid;
+       gid_t s_resgid;
+       unsigned long s_commit_interval;
+#ifdef CONFIG_QUOTA
+       int s_jquota_fmt;
+       char *s_qf_names[MAXQUOTAS];
+#endif
+};
 
 /*
  * Structure of an inode on the disk
@@ -254,7 +306,7 @@ struct ext3_inode {
                struct {
                        __u8    l_i_frag;       /* Fragment number */
                        __u8    l_i_fsize;      /* Fragment size */
-                       __u16   l_i_xid;        /* LRU Context */
+                       __u16   l_i_tag;        /* Context Tag */
                        __le16  l_i_uid_high;   /* these 2 fields    */
                        __le16  l_i_gid_high;   /* were reserved2[0] */
                        __u32   l_i_reserved2;
@@ -274,6 +326,8 @@ struct ext3_inode {
                        __u32   m_i_reserved2[2];
                } masix2;
        } osd2;                         /* OS dependent 2 */
+       __le16  i_extra_isize;
+       __le16  i_pad1;
 };
 
 #define i_size_high    i_dir_acl
@@ -286,7 +340,7 @@ struct ext3_inode {
 #define i_gid_low      i_gid
 #define i_uid_high     osd2.linux2.l_i_uid_high
 #define i_gid_high     osd2.linux2.l_i_gid_high
-#define i_raw_xid      osd2.linux2.l_i_xid
+#define i_raw_tag      osd2.linux2.l_i_tag
 #define i_reserved2    osd2.linux2.l_i_reserved2
 
 #elif defined(__GNU__)
@@ -317,26 +371,31 @@ struct ext3_inode {
 /*
  * Mount flags
  */
-#define EXT3_MOUNT_CHECK               0x0001  /* Do mount-time checks */
-#define EXT3_MOUNT_OLDALLOC            0x0002  /* Don't use the new Orlov allocator */
-#define EXT3_MOUNT_GRPID               0x0004  /* Create files with directory's group */
-#define EXT3_MOUNT_DEBUG               0x0008  /* Some debugging messages */
-#define EXT3_MOUNT_ERRORS_CONT         0x0010  /* Continue on errors */
-#define EXT3_MOUNT_ERRORS_RO           0x0020  /* Remount fs ro on errors */
-#define EXT3_MOUNT_ERRORS_PANIC                0x0040  /* Panic on errors */
-#define EXT3_MOUNT_MINIX_DF            0x0080  /* Mimics the Minix statfs */
-#define EXT3_MOUNT_NOLOAD              0x0100  /* Don't use existing journal*/
-#define EXT3_MOUNT_ABORT               0x0200  /* Fatal error detected */
-#define EXT3_MOUNT_DATA_FLAGS          0x0C00  /* Mode for data writes: */
-  #define EXT3_MOUNT_JOURNAL_DATA      0x0400  /* Write data to journal */
-  #define EXT3_MOUNT_ORDERED_DATA      0x0800  /* Flush data before commit */
-  #define EXT3_MOUNT_WRITEBACK_DATA    0x0C00  /* No data ordering */
-#define EXT3_MOUNT_UPDATE_JOURNAL      0x1000  /* Update the journal format */
-#define EXT3_MOUNT_NO_UID32            0x2000  /* Disable 32-bit UIDs */
-#define EXT3_MOUNT_XATTR_USER          0x4000  /* Extended user attributes */
-#define EXT3_MOUNT_POSIX_ACL           0x8000  /* POSIX Access Control Lists */
-#define EXT3_MOUNT_BARRIER             0x10000 /* Use block barriers */
-#define EXT3_MOUNT_TAG_XID             (1<<16) /* Enable Context Tags */
+#define EXT3_MOUNT_CHECK               0x00001 /* Do mount-time checks */
+#define EXT3_MOUNT_OLDALLOC            0x00002  /* Don't use the new Orlov allocator */
+#define EXT3_MOUNT_GRPID               0x00004 /* Create files with directory's group */
+#define EXT3_MOUNT_DEBUG               0x00008 /* Some debugging messages */
+#define EXT3_MOUNT_ERRORS_CONT         0x00010 /* Continue on errors */
+#define EXT3_MOUNT_ERRORS_RO           0x00020 /* Remount fs ro on errors */
+#define EXT3_MOUNT_ERRORS_PANIC                0x00040 /* Panic on errors */
+#define EXT3_MOUNT_MINIX_DF            0x00080 /* Mimics the Minix statfs */
+#define EXT3_MOUNT_NOLOAD              0x00100 /* Don't use existing journal*/
+#define EXT3_MOUNT_ABORT               0x00200 /* Fatal error detected */
+#define EXT3_MOUNT_DATA_FLAGS          0x00C00 /* Mode for data writes: */
+#define EXT3_MOUNT_JOURNAL_DATA                0x00400 /* Write data to journal */
+#define EXT3_MOUNT_ORDERED_DATA                0x00800 /* Flush data before commit */
+#define EXT3_MOUNT_WRITEBACK_DATA      0x00C00 /* No data ordering */
+#define EXT3_MOUNT_UPDATE_JOURNAL      0x01000 /* Update the journal format */
+#define EXT3_MOUNT_NO_UID32            0x02000  /* Disable 32-bit UIDs */
+#define EXT3_MOUNT_XATTR_USER          0x04000 /* Extended user attributes */
+#define EXT3_MOUNT_POSIX_ACL           0x08000 /* POSIX Access Control Lists */
+#define EXT3_MOUNT_RESERVATION         0x10000 /* Preallocation */
+#define EXT3_MOUNT_BARRIER             0x20000 /* Use block barriers */
+#define EXT3_MOUNT_NOBH                        0x40000 /* No bufferheads */
+#define EXT3_MOUNT_QUOTA               0x80000 /* Some quota option set */
+#define EXT3_MOUNT_USRQUOTA            0x100000 /* "old" user quota */
+#define EXT3_MOUNT_GRPQUOTA            0x200000 /* "old" group quota */
+#define EXT3_MOUNT_TAGGED              (1<<24) /* Enable Context Tags */
 
 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
 #ifndef _LINUX_EXT2_FS_H
@@ -430,7 +489,7 @@ struct ext3_super_block {
         */
        __u8    s_prealloc_blocks;      /* Nr of blocks to try to preallocate*/
        __u8    s_prealloc_dir_blocks;  /* Nr to preallocate for dirs */
-       __u16   s_padding1;
+       __le16  s_reserved_gdt_blocks;  /* Per group desc for online growth */
        /*
         * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
         */
@@ -443,11 +502,13 @@ struct ext3_super_block {
        __u8    s_reserved_char_pad;
        __u16   s_reserved_word_pad;
        __le32  s_default_mount_opts;
-       __le32  s_first_meta_bg;        /* First metablock block group */
+       __le32  s_first_meta_bg;        /* First metablock block group */
        __u32   s_reserved[190];        /* Padding to the end of the block */
 };
 
 #ifdef __KERNEL__
+#include <linux/ext3_fs_i.h>
+#include <linux/ext3_fs_sb.h>
 static inline struct ext3_sb_info * EXT3_SB(struct super_block *sb)
 {
        return sb->s_fs_info;
@@ -456,6 +517,15 @@ static inline struct ext3_inode_info *EXT3_I(struct inode *inode)
 {
        return container_of(inode, struct ext3_inode_info, vfs_inode);
 }
+
+static inline int ext3_valid_inum(struct super_block *sb, unsigned long ino)
+{
+       return ino == EXT3_ROOT_INO ||
+               ino == EXT3_JOURNAL_INO ||
+               ino == EXT3_RESIZE_INO ||
+               (ino >= EXT3_FIRST_INO(sb) &&
+                ino <= le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count));
+}
 #else
 /* Assume that user mode programs are passing in an ext3fs superblock, not
  * a kernel struct super_block.  This will allow us to call the feature-test
@@ -625,6 +695,8 @@ struct ext3_dir_entry_2 {
 #define DX_HASH_HALF_MD4       1
 #define DX_HASH_TEA            2
 
+#ifdef __KERNEL__
+
 /* hash info structure used by the directory hash */
 struct dx_hash_info
 {
@@ -636,7 +708,6 @@ struct dx_hash_info
 
 #define EXT3_HTREE_EOF 0x7fffffff
 
-#ifdef __KERNEL__
 /*
  * Control parameters used by ext3_htree_next_block
  */
@@ -673,6 +744,14 @@ struct dir_private_info {
        __u32           next_hash;
 };
 
+/* calculate the first block number of the group */
+static inline ext3_fsblk_t
+ext3_group_first_block_no(struct super_block *sb, unsigned long group_no)
+{
+       return group_no * (ext3_fsblk_t)EXT3_BLOCKS_PER_GROUP(sb) +
+               le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block);
+}
+
 /*
  * Special error return code only used by dx_probe() and its callers.
  */
@@ -693,16 +772,23 @@ struct dir_private_info {
 /* balloc.c */
 extern int ext3_bg_has_super(struct super_block *sb, int group);
 extern unsigned long ext3_bg_num_gdb(struct super_block *sb, int group);
-extern int ext3_new_block (handle_t *, struct inode *, unsigned long,
-                                           __u32 *, __u32 *, int *);
-extern void ext3_free_blocks (handle_t *, struct inode *, unsigned long,
-                             unsigned long);
-extern unsigned long ext3_count_free_blocks (struct super_block *);
+extern ext3_fsblk_t ext3_new_block (handle_t *handle, struct inode *inode,
+                       ext3_fsblk_t goal, int *errp);
+extern ext3_fsblk_t ext3_new_blocks (handle_t *handle, struct inode *inode,
+                       ext3_fsblk_t goal, unsigned long *count, int *errp);
+extern void ext3_free_blocks (handle_t *handle, struct inode *inode,
+                       ext3_fsblk_t block, unsigned long count);
+extern void ext3_free_blocks_sb (handle_t *handle, struct super_block *sb,
+                                ext3_fsblk_t block, unsigned long count,
+                               unsigned long *pdquot_freed_blocks);
+extern ext3_fsblk_t ext3_count_free_blocks (struct super_block *);
 extern void ext3_check_blocks_bitmap (struct super_block *);
 extern struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb,
                                                    unsigned int block_group,
                                                    struct buffer_head ** bh);
 extern int ext3_should_retry_alloc(struct super_block *sb, int *retries);
+extern void ext3_init_block_alloc_info(struct inode *);
+extern void ext3_rsv_window_add(struct super_block *sb, struct ext3_reserve_window_node *rsv);
 
 /* dir.c */
 extern int ext3_check_dir_entry(const char *, struct inode *,
@@ -731,19 +817,24 @@ extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
 
 
 /* inode.c */
-extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
-extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
-extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
+int ext3_forget(handle_t *handle, int is_metadata, struct inode *inode,
+               struct buffer_head *bh, ext3_fsblk_t blocknr);
+struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
+struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
+int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,
+       sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
+       int create, int extend_disksize);
+extern int ext3_sync_flags(struct inode *inode);
 
 extern void ext3_read_inode (struct inode *);
 extern int  ext3_write_inode (struct inode *, int);
 extern int  ext3_setattr (struct dentry *, struct iattr *);
-extern void ext3_put_inode (struct inode *);
 extern void ext3_delete_inode (struct inode *);
 extern int  ext3_sync_inode (handle_t *, struct inode *);
-extern void ext3_discard_prealloc (struct inode *);
+extern void ext3_discard_reservation (struct inode *);
 extern void ext3_dirty_inode(struct inode *);
 extern int ext3_change_inode_journal_flag(struct inode *, int);
+extern int ext3_get_inode_loc(struct inode *, struct ext3_iloc *);
 extern void ext3_truncate (struct inode *);
 extern void ext3_set_inode_flags(struct inode *);
 extern void ext3_set_aops(struct inode *inode);
@@ -751,6 +842,7 @@ extern void ext3_set_aops(struct inode *inode);
 /* ioctl.c */
 extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
                       unsigned long);
+extern long ext3_compat_ioctl (struct file *, unsigned int, unsigned long);
 
 /* namei.c */
 extern int ext3_orphan_add(handle_t *, struct inode *);
@@ -758,42 +850,39 @@ extern int ext3_orphan_del(handle_t *, struct inode *);
 extern int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash,
                                __u32 start_minor_hash, __u32 *next_hash);
 
+/* resize.c */
+extern int ext3_group_add(struct super_block *sb,
+                               struct ext3_new_group_data *input);
+extern int ext3_group_extend(struct super_block *sb,
+                               struct ext3_super_block *es,
+                               ext3_fsblk_t n_blocks_count);
+
 /* super.c */
 extern void ext3_error (struct super_block *, const char *, const char *, ...)
        __attribute__ ((format (printf, 3, 4)));
 extern void __ext3_std_error (struct super_block *, const char *, int);
 extern void ext3_abort (struct super_block *, const char *, const char *, ...)
        __attribute__ ((format (printf, 3, 4)));
-extern NORET_TYPE void ext3_panic (struct super_block *, const char *,
-                                  const char *, ...)
-       __attribute__ ((NORET_AND format (printf, 3, 4)));
 extern void ext3_warning (struct super_block *, const char *, const char *, ...)
        __attribute__ ((format (printf, 3, 4)));
 extern void ext3_update_dynamic_rev (struct super_block *sb);
-extern void ext3_put_super (struct super_block *);
-extern void ext3_write_super (struct super_block *);
-extern void ext3_write_super_lockfs (struct super_block *);
-extern void ext3_unlockfs (struct super_block *);
-extern int ext3_remount (struct super_block *, int *, char *);
-extern int ext3_statfs (struct super_block *, struct kstatfs *);
 
 #define ext3_std_error(sb, errno)                              \
 do {                                                           \
        if ((errno))                                            \
                __ext3_std_error((sb), __FUNCTION__, (errno));  \
 } while (0)
-extern const char *ext3_decode_error(struct super_block *sb, int errno, char nbuf[16]);
 
 /*
  * Inodes and files operations
  */
 
 /* dir.c */
-extern struct file_operations ext3_dir_operations;
+extern const struct file_operations ext3_dir_operations;
 
 /* file.c */
 extern struct inode_operations ext3_file_inode_operations;
-extern struct file_operations ext3_file_operations;
+extern const struct file_operations ext3_file_operations;
 
 /* namei.c */
 extern struct inode_operations ext3_dir_inode_operations;