X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=include%2Flinux%2Fjbd.h;h=6a425e370cb3db18d15983da16fa0ae87160c283;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=0a625c3cd38b4afe1c6c539ff9f6f3d616e6d8a5;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/include/linux/jbd.h b/include/linux/jbd.h index 0a625c3cd..6a425e370 100644 --- a/include/linux/jbd.h +++ b/include/linux/jbd.h @@ -16,8 +16,6 @@ #ifndef _LINUX_JBD_H #define _LINUX_JBD_H -#if defined(CONFIG_JBD) || defined(CONFIG_JBD_MODULE) || !defined(__KERNEL__) - /* Allow this file to be included directly into e2fsprogs */ #ifndef __KERNEL__ #include "jfs_compat.h" @@ -25,9 +23,14 @@ #define jfs_debug jbd_debug #else +#include #include #include #include +#include +#include +#include + #include #endif @@ -68,7 +71,7 @@ extern int journal_enable_debug; #define jbd_debug(f, a...) /**/ #endif -extern void * __jbd_kmalloc (const char *where, size_t size, int flags, int retry); +extern void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry); #define jbd_kmalloc(size, flags) \ __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry) #define jbd_rep_kmalloc(size, flags) \ @@ -137,9 +140,9 @@ typedef struct journal_s journal_t; /* Journal control structure */ */ typedef struct journal_header_s { - __u32 h_magic; - __u32 h_blocktype; - __u32 h_sequence; + __be32 h_magic; + __be32 h_blocktype; + __be32 h_sequence; } journal_header_t; @@ -148,8 +151,8 @@ typedef struct journal_header_s */ typedef struct journal_block_tag_s { - __u32 t_blocknr; /* The on-disk block number */ - __u32 t_flags; /* See below */ + __be32 t_blocknr; /* The on-disk block number */ + __be32 t_flags; /* See below */ } journal_block_tag_t; /* @@ -159,7 +162,7 @@ typedef struct journal_block_tag_s typedef struct journal_revoke_header_s { journal_header_t r_header; - int r_count; /* Count of bytes used in the block */ + __be32 r_count; /* Count of bytes used in the block */ } journal_revoke_header_t; @@ -180,35 +183,35 @@ typedef struct journal_superblock_s /* 0x000C */ /* Static information describing the journal */ - __u32 s_blocksize; /* journal device blocksize */ - __u32 s_maxlen; /* total blocks in journal file */ - __u32 s_first; /* first block of log information */ + __be32 s_blocksize; /* journal device blocksize */ + __be32 s_maxlen; /* total blocks in journal file */ + __be32 s_first; /* first block of log information */ /* 0x0018 */ /* Dynamic information describing the current state of the log */ - __u32 s_sequence; /* first commit ID expected in log */ - __u32 s_start; /* blocknr of start of log */ + __be32 s_sequence; /* first commit ID expected in log */ + __be32 s_start; /* blocknr of start of log */ /* 0x0020 */ /* Error value, as set by journal_abort(). */ - __s32 s_errno; + __be32 s_errno; /* 0x0024 */ /* Remaining fields are only valid in a version-2 superblock */ - __u32 s_feature_compat; /* compatible feature set */ - __u32 s_feature_incompat; /* incompatible feature set */ - __u32 s_feature_ro_compat; /* readonly-compatible feature set */ + __be32 s_feature_compat; /* compatible feature set */ + __be32 s_feature_incompat; /* incompatible feature set */ + __be32 s_feature_ro_compat; /* readonly-compatible feature set */ /* 0x0030 */ __u8 s_uuid[16]; /* 128-bit uuid for journal */ /* 0x0040 */ - __u32 s_nr_users; /* Nr of filesystems sharing log */ + __be32 s_nr_users; /* Nr of filesystems sharing log */ - __u32 s_dynsuper; /* Blocknr of dynamic superblock copy*/ + __be32 s_dynsuper; /* Blocknr of dynamic superblock copy*/ /* 0x0048 */ - __u32 s_max_transaction; /* Limit of journal blocks per trans.*/ - __u32 s_max_trans_data; /* Limit of data blocks per trans. */ + __be32 s_max_transaction; /* Limit of journal blocks per trans.*/ + __be32 s_max_trans_data; /* Limit of data blocks per trans. */ /* 0x0050 */ __u32 s_padding[44]; @@ -239,7 +242,6 @@ typedef struct journal_superblock_s #include #include -#include #define JBD_ASSERTIONS #ifdef JBD_ASSERTIONS @@ -277,13 +279,15 @@ void buffer_assertion_failure(struct buffer_head *bh); #define J_EXPECT_JH(jh, expr, why...) J_ASSERT_JH(jh, expr) #else #define __journal_expect(expr, why...) \ - do { \ - if (!(expr)) { \ + ({ \ + int val = (expr); \ + if (!val) { \ printk(KERN_ERR \ "EXT3-fs unexpected failure: %s;\n",# expr); \ - printk(KERN_ERR why); \ + printk(KERN_ERR why "\n"); \ } \ - } while (0) + val; \ + }) #define J_EXPECT(expr, why...) __journal_expect(expr, ## why) #define J_EXPECT_BH(bh, expr, why...) __journal_expect(expr, ## why) #define J_EXPECT_JH(jh, expr, why...) __journal_expect(expr, ## why) @@ -299,6 +303,7 @@ enum jbd_state_bits { BH_JBDDirty, /* Is dirty but journaled */ BH_State, /* Pins most journal_head state */ BH_JournalHead, /* Pins bh->b_private and jh->b_bh */ + BH_Unshadow, /* Dummy bit, for BJ_Shadow wakeup filtering */ }; BUFFER_FNS(JBD, jbd) @@ -351,27 +356,6 @@ static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh) bit_spin_unlock(BH_JournalHead, &bh->b_state); } -#define HAVE_JOURNAL_CALLBACK_STATUS -/** - * struct journal_callback - Base structure for callback information. - * @jcb_list: list information for other callbacks attached to the same handle. - * @jcb_func: Function to call with this callback structure. - * - * This struct is a 'seed' structure for a using with your own callback - * structs. If you are using callbacks you must allocate one of these - * or another struct of your own definition which has this struct - * as it's first element and pass it to journal_callback_set(). - * - * This is used internally by jbd to maintain callback information. - * - * See journal_callback_set for more information. - **/ -struct journal_callback { - struct list_head jcb_list; /* t_jcb_lock */ - void (*jcb_func)(struct journal_callback *jcb, int error); - /* user data goes here */ -}; - struct jbd_revoke_table_s; /** @@ -380,7 +364,6 @@ struct jbd_revoke_table_s; * @h_transaction: Which compound transaction is this update a part of? * @h_buffer_credits: Number of remaining buffers we are allowed to dirty. * @h_ref: Reference count on this handle - * @h_jcb: List of application registered callbacks for this handle. * @h_err: Field for caller's use to track errors through large fs operations * @h_sync: flag for sync-on-close * @h_jdata: flag to force data journaling @@ -406,13 +389,6 @@ struct handle_s /* operations */ int h_err; - /* - * List of application registered callbacks for this handle. The - * function(s) will be called after the transaction that this handle is - * part of has been committed to disk. [t_jcb_lock] - */ - struct list_head h_jcb; - /* Flags [no locking] */ unsigned int h_sync: 1; /* sync-on-close */ unsigned int h_jdata: 1; /* force data journaling */ @@ -454,8 +430,6 @@ struct handle_s * j_state_lock * ->j_list_lock (journal_unmap_buffer) * - * t_handle_lock - * ->t_jcb_lock */ struct transaction_s @@ -579,15 +553,6 @@ struct transaction_s */ int t_handle_count; - /* - * Protects the callback list - */ - spinlock_t t_jcb_lock; - /* - * List of registered callback functions for this transaction. - * Called when the transaction is committed. [t_jcb_lock] - */ - struct list_head t_jcb; }; /** @@ -599,6 +564,7 @@ struct transaction_s * @j_sb_buffer: First part of superblock buffer * @j_superblock: Second part of superblock buffer * @j_format_version: Version of the superblock format + * @j_state_lock: Protect the various scalars in the journal * @j_barrier_count: Number of processes waiting to create a barrier lock * @j_barrier: The barrier lock itself * @j_running_transaction: The current running transaction.. @@ -612,7 +578,7 @@ struct transaction_s * @j_wait_checkpoint: Wait queue to trigger checkpointing * @j_wait_commit: Wait queue to trigger commit * @j_wait_updates: Wait queue to wait for updates to complete - * @j_checkpoint_sem: Semaphore for locking against concurrent checkpoints + * @j_checkpoint_mutex: Mutex for locking against concurrent checkpoints * @j_head: Journal head - identifies the first unused block in the journal * @j_tail: Journal tail - identifies the oldest still-used block in the * journal. @@ -626,6 +592,7 @@ struct transaction_s * @j_fs_dev: Device which holds the client fs. For internal journal this will * be equal to j_dev * @j_maxlen: Total maximum capacity of the journal region on disk. + * @j_list_lock: Protects the buffer lists and internal buffer state. * @j_inode: Optional inode where we store the journal. If present, all journal * block numbers are mapped into this inode via bmap(). * @j_tail_sequence: Sequence number of the oldest transaction in the log @@ -641,8 +608,15 @@ struct transaction_s * @j_commit_interval: What is the maximum transaction lifetime before we begin * a commit? * @j_commit_timer: The timer used to wakeup the commit thread + * @j_revoke_lock: Protect the revoke table * @j_revoke: The revoke table - maintains the list of revoked blocks in the * current transaction. + * @j_revoke_table: alternate revoke tables for j_revoke + * @j_wbuf: array of buffer_heads for journal_commit_transaction + * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the + * number that will fit in j_blocksize + * @j_last_sync_writer: most recent pid which did a synchronous write + * @j_private: An opaque pointer to fs-private information. */ struct journal_s @@ -674,7 +648,7 @@ struct journal_s int j_barrier_count; /* The barrier lock itself */ - struct semaphore j_barrier; + struct mutex j_barrier; /* * Transactions: The current running transaction... @@ -716,7 +690,7 @@ struct journal_s wait_queue_head_t j_wait_updates; /* Semaphore for locking against concurrent checkpoints */ - struct semaphore j_checkpoint_sem; + struct mutex j_checkpoint_mutex; /* * Journal head: identifies the first unused block in the journal. @@ -815,7 +789,7 @@ struct journal_s unsigned long j_commit_interval; /* The timer used to wakeup the commit thread: */ - struct timer_list *j_commit_timer; + struct timer_list j_commit_timer; /* * The revoke table: maintains the list of revoked blocks in the @@ -825,6 +799,14 @@ struct journal_s struct jbd_revoke_table_s *j_revoke; struct jbd_revoke_table_s *j_revoke_table[2]; + /* + * array of bhs for journal_commit_transaction + */ + struct buffer_head **j_wbuf; + int j_wbufsize; + + pid_t j_last_sync_writer; + /* * An opaque pointer to fs-private information. ext3 puts its * superblock pointer here @@ -840,6 +822,7 @@ struct journal_s #define JFS_ACK_ERR 0x004 /* The errno in the sb has been acked */ #define JFS_FLUSHED 0x008 /* The journal superblock has been flushed */ #define JFS_LOADED 0x010 /* The journal superblock has been loaded */ +#define JFS_BARRIER 0x020 /* Use IDE barriers */ /* * Function declarations for the journaling transaction and buffer @@ -847,6 +830,7 @@ struct journal_s */ /* Filing buffers */ +extern void __journal_temp_unlink_buffer(struct journal_head *jh); extern void journal_unfile_buffer(journal_t *, struct journal_head *); extern void __journal_unfile_buffer(struct journal_head *); extern void __journal_refile_buffer(struct journal_head *); @@ -903,26 +887,19 @@ static inline handle_t *journal_current_handle(void) extern handle_t *journal_start(journal_t *, int nblocks); extern int journal_restart (handle_t *, int nblocks); extern int journal_extend (handle_t *, int nblocks); -extern int journal_get_write_access(handle_t *, struct buffer_head *, - int *credits); +extern int journal_get_write_access(handle_t *, struct buffer_head *); extern int journal_get_create_access (handle_t *, struct buffer_head *); -extern int journal_get_undo_access(handle_t *, struct buffer_head *, - int *credits); +extern int journal_get_undo_access(handle_t *, struct buffer_head *); extern int journal_dirty_data (handle_t *, struct buffer_head *); extern int journal_dirty_metadata (handle_t *, struct buffer_head *); -extern void journal_release_buffer (handle_t *, struct buffer_head *, - int credits); -extern void journal_forget (handle_t *, struct buffer_head *); +extern void journal_release_buffer (handle_t *, struct buffer_head *); +extern int journal_forget (handle_t *, struct buffer_head *); extern void journal_sync_buffer (struct buffer_head *); -extern int journal_invalidatepage(journal_t *, +extern void journal_invalidatepage(journal_t *, struct page *, unsigned long); -extern int journal_try_to_free_buffers(journal_t *, struct page *, int); +extern int journal_try_to_free_buffers(journal_t *, struct page *, gfp_t); extern int journal_stop(handle_t *); extern int journal_flush (journal_t *); -extern void journal_callback_set(handle_t *handle, - void (*fn)(struct journal_callback *,int), - struct journal_callback *jcb); - extern void journal_lock_updates (journal_t *); extern void journal_unlock_updates (journal_t *); @@ -945,7 +922,6 @@ extern int journal_wipe (journal_t *, int); extern int journal_skip_recovery (journal_t *); extern void journal_update_superblock (journal_t *, int); extern void __journal_abort_hard (journal_t *); -extern void __journal_abort_soft (journal_t *, int); extern void journal_abort (journal_t *, int); extern int journal_errno (journal_t *); extern void journal_ack_err (journal_t *); @@ -966,7 +942,7 @@ void journal_put_journal_head(struct journal_head *jh); */ extern kmem_cache_t *jbd_handle_cache; -static inline handle_t *jbd_alloc_handle(int gfp_flags) +static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags) { return kmem_cache_alloc(jbd_handle_cache, gfp_flags); } @@ -1006,6 +982,7 @@ int __log_space_left(journal_t *); /* Called with journal locked */ int log_start_commit(journal_t *journal, tid_t tid); int __log_start_commit(journal_t *journal, tid_t tid); int journal_start_commit(journal_t *journal, tid_t *tid); +int journal_force_commit_nested(journal_t *journal); int log_wait_commit(journal_t *journal, tid_t tid); int log_do_checkpoint(journal_t *journal); @@ -1101,12 +1078,6 @@ extern int jbd_blocks_per_page(struct inode *inode); #ifdef __KERNEL__ -#ifdef CONFIG_SMP -#define assert_spin_locked(lock) J_ASSERT(spin_is_locked(lock)) -#else -#define assert_spin_locked(lock) do {} while(0) -#endif - #define buffer_trace_init(bh) do {} while (0) #define print_buffer_fields(bh) do {} while (0) #define print_buffer_trace(bh) do {} while (0) @@ -1116,19 +1087,4 @@ extern int jbd_blocks_per_page(struct inode *inode); #endif /* __KERNEL__ */ -#endif /* CONFIG_JBD || CONFIG_JBD_MODULE || !__KERNEL__ */ - -/* - * Compatibility no-ops which allow the kernel to compile without CONFIG_JBD - * go here. - */ - -#if defined(__KERNEL__) && !(defined(CONFIG_JBD) || defined(CONFIG_JBD_MODULE)) - -#define J_ASSERT(expr) do {} while (0) -#define J_ASSERT_BH(bh, expr) do {} while (0) -#define buffer_jbd(bh) 0 -#define journal_buffer_journal_lru(bh) 0 - -#endif /* defined(__KERNEL__) && !defined(CONFIG_JBD) */ #endif /* _LINUX_JBD_H */