/* clear bit for the given block in bit map */
@@ -599,7 +597,6 @@
if (hint->formatted_node || hint->inode == NULL) {
return 0;
}
-
hash_in = le32_to_cpu((INODE_PKEY(hint->inode))->k_dir_id);
border = hint->beg + (unsigned long) keyed_hash(((char *) (&hash_in)), 4) % (hint->end - hint->beg - 1);
if (border > hint->search_start)
Index: linux.d/fs/reiserfs/journal.c
===================================================================
--- linux.d.orig/fs/reiserfs/journal.c 2003-12-03 19:07:52.000000000 -0500
+++ linux.d/fs/reiserfs/journal.c 2003-12-03 19:30:33.000000000 -0500
@@ -64,12 +64,15 @@
*/
static int reiserfs_mounted_fs_count = 0 ;
+static struct list_head kreiserfsd_supers = LIST_HEAD_INIT(kreiserfsd_supers);
+
/* wake this up when you add something to the commit thread task queue */
DECLARE_WAIT_QUEUE_HEAD(reiserfs_commit_thread_wait) ;
/* wait on this if you need to be sure you task queue entries have been run */
static DECLARE_WAIT_QUEUE_HEAD(reiserfs_commit_thread_done) ;
DECLARE_TASK_QUEUE(reiserfs_commit_thread_tq) ;
+DECLARE_MUTEX(kreiserfsd_sem) ;
#define JOURNAL_TRANS_HALF 1018 /* must be correct to keep the desc and commit
structs at 4k */
@@ -574,17 +577,12 @@
/* lock the current transaction */
inline static void lock_journal(struct super_block *p_s_sb) {
PROC_INFO_INC( p_s_sb, journal.lock_journal );
- while(atomic_read(&(SB_JOURNAL(p_s_sb)->j_wlock)) > 0) {
- PROC_INFO_INC( p_s_sb, journal.lock_journal_wait );
- sleep_on(&(SB_JOURNAL(p_s_sb)->j_wait)) ;
- }
- atomic_set(&(SB_JOURNAL(p_s_sb)->j_wlock), 1) ;
+ down(&SB_JOURNAL(p_s_sb)->j_lock);
}
@@ -1218,7 +1215,6 @@
if (run++ == 0) {
goto loop_start ;
}
-
atomic_set(&(jl->j_flushing), 0) ;
wake_up(&(jl->j_flush_wait)) ;
return ret ;
@@ -1248,7 +1244,7 @@
while(i != start) {
jl = SB_JOURNAL_LIST(s) + i ;
age = CURRENT_TIME - jl->j_timestamp ;
- if (jl->j_len > 0 && // age >= (JOURNAL_MAX_COMMIT_AGE * 2) &&
+ if (jl->j_len > 0 && age >= JOURNAL_MAX_COMMIT_AGE &&
atomic_read(&(jl->j_nonzerolen)) > 0 &&
atomic_read(&(jl->j_commit_left)) == 0) {
@@ -1327,6 +1323,10 @@
static int do_journal_release(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, int error) {
struct reiserfs_transaction_handle myth ;
+ down(&kreiserfsd_sem);
+ list_del(&p_s_sb->u.reiserfs_sb.s_reiserfs_supers);
+ up(&kreiserfsd_sem);
+
/* we only want to flush out transactions if we were called with error == 0
*/
if (!error && !(p_s_sb->s_flags & MS_RDONLY)) {
@@ -1831,11 +1831,6 @@
jl = SB_JOURNAL_LIST(ct->p_s_sb) + ct->jindex ;
@@ -2389,7 +2399,7 @@
reiserfs_panic(th->t_super, "journal-1577: handle trans id %ld != current trans id %ld\n",
th->t_trans_id, SB_JOURNAL(p_s_sb)->j_trans_id);
}
- p_s_sb->s_dirt = 1 ;
+ p_s_sb->s_dirt = 1;
prepared = test_and_clear_bit(BH_JPrepared, &bh->b_state) ;
/* already in this transaction, we are done */
@@ -2637,12 +2647,8 @@
** flushes any old transactions to disk
** ends the current transaction if it is too old
**
-** also calls flush_journal_list with old_only == 1, which allows me to reclaim
-** memory and such from the journal lists whose real blocks are all on disk.
-**
-** called by sync_dev_journal from buffer.c
*/
-int flush_old_commits(struct super_block *p_s_sb, int immediate) {
+int reiserfs_flush_old_commits(struct super_block *p_s_sb) {
int i ;
int count = 0;
int start ;
@@ -2659,8 +2665,7 @@
/* starting with oldest, loop until we get to the start */
i = (SB_JOURNAL_LIST_INDEX(p_s_sb) + 1) % JOURNAL_LIST_COUNT ;
while(i != start) {
- if (SB_JOURNAL_LIST(p_s_sb)[i].j_len > 0 && ((now - SB_JOURNAL_LIST(p_s_sb)[i].j_timestamp) > SB_JOURNAL_MAX_COMMIT_AGE(p_s_sb) ||
- immediate)) {
+ if (SB_JOURNAL_LIST(p_s_sb)[i].j_len > 0 && ((now - SB_JOURNAL_LIST(p_s_sb)[i].j_timestamp) > SB_JOURNAL_MAX_COMMIT_AGE(p_s_sb))) {
/* we have to check again to be sure the current transaction did not change */
if (i != SB_JOURNAL_LIST_INDEX(p_s_sb)) {
flush_commit_list(p_s_sb, SB_JOURNAL_LIST(p_s_sb) + i, 1) ;
@@ -2669,26 +2674,26 @@
i = (i + 1) % JOURNAL_LIST_COUNT ;
count++ ;
}
+
/* now, check the current transaction. If there are no writers, and it is too old, finish it, and
** force the commit blocks to disk
*/
- if (!immediate && atomic_read(&(SB_JOURNAL(p_s_sb)->j_wcount)) <= 0 &&
+ if (atomic_read(&(SB_JOURNAL(p_s_sb)->j_wcount)) <= 0 &&
SB_JOURNAL(p_s_sb)->j_trans_start_time > 0 &&
SB_JOURNAL(p_s_sb)->j_len > 0 &&
(now - SB_JOURNAL(p_s_sb)->j_trans_start_time) > SB_JOURNAL_MAX_TRANS_AGE(p_s_sb)) {
journal_join(&th, p_s_sb, 1) ;
reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
journal_mark_dirty(&th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
- do_journal_end(&th, p_s_sb,1, COMMIT_NOW) ;
- } else if (immediate) { /* belongs above, but I wanted this to be very explicit as a special case. If they say to
- flush, we must be sure old transactions hit the disk too. */
- journal_join(&th, p_s_sb, 1) ;
- reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
- journal_mark_dirty(&th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
+
+ /* we're only being called from kreiserfsd, it makes no sense to do
+ ** an async commit so that kreiserfsd can do it later
+ */
do_journal_end(&th, p_s_sb,1, COMMIT_NOW | WAIT) ;
- }
- reiserfs_journal_kupdate(p_s_sb) ;
- return 0 ;
+ }
+ reiserfs_journal_kupdate(p_s_sb) ;
+
+ return p_s_sb->s_dirt;
}
/*
@@ -2727,7 +2732,7 @@
if (SB_JOURNAL(p_s_sb)->j_len == 0) {
int wcount = atomic_read(&(SB_JOURNAL(p_s_sb)->j_wcount)) ;
unlock_journal(p_s_sb) ;
- if (atomic_read(&(SB_JOURNAL(p_s_sb)->j_jlock)) > 0 && wcount <= 0) {
+ if (atomic_read(&(SB_JOURNAL(p_s_sb)->j_jlock)) > 0 && wcount <= 0) {
atomic_dec(&(SB_JOURNAL(p_s_sb)->j_jlock)) ;
wake_up(&(SB_JOURNAL(p_s_sb)->j_join_wait)) ;
}
@@ -3017,6 +3022,7 @@
** it tells us if we should continue with the journal_end, or just return
*/
if (!check_journal_end(th, p_s_sb, nblocks, flags)) {
+ p_s_sb->s_dirt = 1;
return 0 ;
}
@@ -3185,14 +3191,12 @@
/* write any buffers that must hit disk before this commit is done */
fsync_buffers_list(&(SB_JOURNAL(p_s_sb)->j_dirty_buffers)) ;
- /* honor the flush and async wishes from the caller */
+ /* honor the flush wishes from the caller. simple commits can
+ * be done outside the journal lock, they are done below
+ */
if (flush) {
flush_commit_list(p_s_sb, SB_JOURNAL_LIST(p_s_sb) + orig_jindex, 1) ;
flush_journal_list(p_s_sb, SB_JOURNAL_LIST(p_s_sb) + orig_jindex , 1) ;
- } else if (wait_on_commit) {
- flush_commit_list(p_s_sb, SB_JOURNAL_LIST(p_s_sb) + orig_jindex, 1) ;
- } else {
- commit_flush_async(p_s_sb, orig_jindex) ;
}
/* reset journal values for the next transaction */
@@ -3254,5 +3258,15 @@
atomic_set(&(SB_JOURNAL(p_s_sb)->j_jlock), 0) ;
/* wake up any body waiting to join. */
wake_up(&(SB_JOURNAL(p_s_sb)->j_join_wait)) ;
+
+ if (!flush) {
+ if (current->need_resched)
+ schedule() ;
+ if (wait_on_commit) {
+ flush_commit_list(p_s_sb, SB_JOURNAL_LIST(p_s_sb) + orig_jindex, 1) ;
+ } else {
+ commit_flush_async(p_s_sb, orig_jindex) ;
+ }
+ }
return 0 ;
}
Index: linux.d/fs/reiserfs/objectid.c
===================================================================
--- linux.d.orig/fs/reiserfs/objectid.c 2003-12-03 19:25:22.000000000 -0500
+++ linux.d/fs/reiserfs/objectid.c 2003-12-03 19:25:44.000000000 -0500
@@ -87,7 +87,6 @@
}
/* start at the beginning of the objectid map (i = 0) and go to
the end of it (i = disk_sb->s_oid_cursize). Linear search is
Index: linux.d/fs/reiserfs/super.c
===================================================================
--- linux.d.orig/fs/reiserfs/super.c 2003-12-03 19:25:22.000000000 -0500
+++ linux.d/fs/reiserfs/super.c 2003-12-03 19:25:44.000000000 -0500
@@ -50,22 +50,28 @@
static int reiserfs_remount (struct super_block * s, int * flags, char * data);
static int reiserfs_statfs (struct super_block * s, struct statfs * buf);