diff -puN fs/reiser4/vfs_ops.c~reiser4-update-3 fs/reiser4/vfs_ops.c
--- linux-2.6.12-rc3-mm3/fs/reiser4/vfs_ops.c~reiser4-update-3 2005-05-11 18:04:31.419719298 +0400
+++ linux-2.6.12-rc3-mm3-vs/fs/reiser4/vfs_ops.c 2005-05-11 18:04:31.480723729 +0400
@@ -559,7 +559,7 @@ reiser4_put_inode(struct inode *inode)
* Called by reiser4_sync_inodes(), during speculative write-back (through
* pdflush, or balance_dirty_pages()).
*/
-static void
+void
writeout(struct super_block *sb, struct writeback_control *wbc)
{
long written = 0;
@@ -570,10 +570,6 @@ writeout(struct super_block *sb, struct
* nothing to flush, commits some atoms.
*/
- /* reiser4 has its own means of periodical write-out */
- if (wbc->for_kupdate)
- return;
-
/* Commit all atoms if reiser4_writepages() is called from sys_sync() or
sys_fsync(). */
if (wbc->sync_mode != WB_SYNC_NONE) {
@@ -593,9 +589,7 @@ writeout(struct super_block *sb, struct
/* do not put more requests to overload write queue */
if (wbc->nonblocking &&
bdi_write_congested(mapping->backing_dev_info)) {
-
blk_run_address_space(mapping);
- /*blk_run_queues();*/
wbc->encountered_congestion = 1;
break;
}
@@ -620,21 +614,26 @@ reiser4_sync_inodes(struct super_block *
{
reiser4_context ctx;
+ /* reiser4 has its own means of periodical write-out */
+ if (wbc->for_kupdate)
+ return;
+
+ assert("", wbc->older_than_this == NULL);
+
init_context(&ctx, sb);
- wbc->older_than_this = NULL;
/*
- * What we are trying to do here is to capture all "anonymous" pages.
+ * call reiser4_writepages for each of dirty inodes to turn dirty pages
+ * into transactions if they were not yet.
*/
generic_sync_sb_inodes(sb, wbc);
- /*capture_reiser4_inodes(sb, wbc);*/
- spin_unlock(&inode_lock);
+
+ /* flush goes here */
writeout(sb, wbc);
- oid = (void *)(unsigned long)get_inode_oid(page->mapping->host);
-
/* is_page_cache_freeable() check
(mapping + private + page_cache_get() by shrink_cache()) */
if (page_count(page) > 3)
@@ -557,19 +554,6 @@ reiser4_releasepage(struct page *page, i
#undef INC_NSTAT
#undef INC_STAT
-reiser4_internal void
-move_inode_out_from_sync_inodes_loop(struct address_space * mapping)
-{
- /* work around infinite loop in pdflush->sync_sb_inodes. */
- /* Problem: ->writepages() is supposed to submit io for the pages from
- * ->io_pages list and to clean this list. */
- mapping->host->dirtied_when = jiffies;
- spin_lock(&inode_lock);
- list_move(&mapping->host->i_list, &mapping->host->i_sb->s_dirty);
- spin_unlock(&inode_lock);
-
-}
-
/* reiser4 writepages() address space operation this captures anonymous pages
and anonymous jnodes. Anonymous pages are pages which are dirtied via
mmapping. Anonymous jnodes are ones which were created by reiser4_writepage
@@ -584,12 +568,21 @@ reiser4_writepages(struct address_space
inode = mapping->host;
fplug = inode_file_plugin(inode);
- if (fplug != NULL && fplug->capture != NULL)
+ if (fplug != NULL && fplug->capture != NULL) {
/* call file plugin method to capture anonymous pages and
anonymous jnodes */
ret = fplug->capture(inode, wbc);
+ if (is_in_reiser4_context()) {
+ if (get_current_context()->nr_captured >= CAPTURE_APAGE_BURST) {
+ /* there are already pages to flush, flush them
+ out, do not delay until end of
+ reiser4_sync_inodes */
+ writeout(inode->i_sb, wbc);
+ get_current_context()->nr_captured = 0;
+ }
+ }
+ }
-
-#define CAPTURE_APAGE_BURST (1024l)
-
/* look for pages tagged REISER4_MOVED starting from the index-th page, return
number of captured pages, update index to next page after the last found
one */
@@ -1349,23 +1338,7 @@ capture_unix_file(struct inode *inode, s
*/
assert("", LOCK_CNT_NIL(inode_sem_w));
assert("", LOCK_CNT_NIL(inode_sem_r));
-#if 0
- if (is_in_reiser4_context()) {
- if (down_read_trylock(&uf_info->latch) == 0) {
-/* ZAM-FIXME-HANS: please explain this error handling here, grep for
- * all instances of returning EBUSY, and tell me whether any of them
- * represent busy loops that we should recode. Also tell me whether
- * any of them fail to return EBUSY to user space, and if yes, then
- * recode them to not use the EBUSY macro.*/
- warning("", "does this ever happen?");
- result = RETERR(-EBUSY);
- reiser4_exit_context(&ctx);
- break;
- }
- } else
- down_read(&uf_info->latch);
- LOCK_CNT_INC(inode_sem_r);
-#endif
+
txn_restart_current();
get_nonexclusive_access(uf_info, 0);
while (to_capture > 0) {
@@ -1391,7 +1364,7 @@ capture_unix_file(struct inode *inode, s
if (result < 0)
break;
to_capture -= result;
- wbc->nr_to_write -= result;
+ get_current_context()->nr_captured -= result;
if (jindex == (pgoff_t)-1) {
assert("vs-1728", pindex == (pgoff_t)-1);
@@ -1400,13 +1373,9 @@ capture_unix_file(struct inode *inode, s
}
if (to_capture <= 0)
/* there may be left more pages */
- redirty_inode(inode);
+ __mark_inode_dirty(inode, I_DIRTY_PAGES);
/* count non-trivial jnode_set_dirty() calls */
unsigned long nr_marked_dirty;
+
+ /* reiser4_sync_inodes calls (via generic_sync_sb_inodes)
+ * reiser4_writepages for each of dirty inodes. Reiser4_writepages
+ * captures pages. When number of pages captured in one
+ * reiser4_sync_inodes reaches some threshold - some atoms get
+ * flushed */
+ int nr_captured;
#if REISER4_DEBUG
/* A link of all active contexts. */
context_list_link contexts_link;
diff -puN fs/reiser4/flush.c~reiser4-update-3 fs/reiser4/flush.c
--- linux-2.6.12-rc3-mm3/fs/reiser4/flush.c~reiser4-update-3 2005-05-11 18:04:31.452721695 +0400
+++ linux-2.6.12-rc3-mm3-vs/fs/reiser4/flush.c 2005-05-11 18:04:31.494724746 +0400
@@ -631,7 +631,8 @@ static int prepare_flush_pos(flush_pos_t
audit.
*/
-static int jnode_flush(jnode * node, long *nr_to_flush, long * nr_written, flush_queue_t * fq, int flags)
+static int
+jnode_flush(jnode *node, long *nr_written, flush_queue_t *fq, int flags)
{
long ret = 0;
flush_scan right_scan;
@@ -665,7 +666,6 @@ static int jnode_flush(jnode * node, lon
/* Initialize a flush position. */
pos_init(&flush_pos);
- if (nr_to_flush != NULL) {
- if (ret >= 0) {
- (*nr_to_flush) = flush_pos.prep_or_free_cnt;
- } else {
- (*nr_to_flush) = 0;
- }
- }
-
switch (ret) {
case -E_REPEAT:
case -EINVAL:
@@ -985,7 +977,7 @@ flush_current_atom (int flags, long *nr_
jref(node);
UNLOCK_ATOM(*atom);
UNLOCK_JNODE(node);
- ret = jnode_flush(node, NULL, nr_submitted, fq, flags);
+ ret = jnode_flush(node, nr_submitted, fq, flags);
jput(node);
}
diff -puN fs/reiser4/flush.h~reiser4-update-3 fs/reiser4/flush.h
--- linux-2.6.12-rc3-mm3/fs/reiser4/flush.h~reiser4-update-3 2005-05-11 18:04:31.459722204 +0400
+++ linux-2.6.12-rc3-mm3-vs/fs/reiser4/flush.h 2005-05-11 18:04:31.497724964 +0400
@@ -103,8 +103,6 @@ struct flush_position {
reiser4_blocknr_hint preceder; /* The flush 'hint' state. */
int leaf_relocate; /* True if enough leaf-level nodes were
* found to suggest a relocate policy. */
- long *nr_to_flush; /* If called under memory pressure,
- * indicates how many nodes the VM asked to flush. */
int alloc_cnt; /* The number of nodes allocated during squeeze and allococate. */
int prep_or_free_cnt; /* The number of nodes prepared for write (allocate) or squeezed and freed. */
flush_queue_t *fq;
diff -puN fs/reiser4/vfs_ops.h~reiser4-update-3 fs/reiser4/vfs_ops.h
--- linux-2.6.12-rc3-mm3/fs/reiser4/vfs_ops.h~reiser4-update-3 2005-05-11 18:04:31.466722712 +0400
+++ linux-2.6.12-rc3-mm3-vs/fs/reiser4/vfs_ops.h 2005-05-11 18:04:31.498725036 +0400
@@ -38,9 +38,12 @@ extern int reiser4_invalidatepage(struct
extern int reiser4_releasepage(struct page *page, int gfp);
extern int reiser4_writepages(struct address_space *, struct writeback_control *wbc);
extern int reiser4_start_up_io(struct page *page);
-extern void move_inode_out_from_sync_inodes_loop(struct address_space * mapping);
extern void reiser4_clear_page_dirty(struct page *);
extern void reiser4_throttle_write(struct inode*);
+
+#define CAPTURE_APAGE_BURST (1024l)
+void writeout(struct super_block *, struct writeback_control *);
+
/*
* this is used to speed up lookups for directory entry: on initial call to
* ->lookup() seal and coord of directory entry (if found, that is) are stored
diff -puN fs/reiser4/plugin/item/tail.c~reiser4-update-3 fs/reiser4/plugin/item/tail.c
--- linux-2.6.12-rc3-mm3/fs/reiser4/plugin/item/tail.c~reiser4-update-3 2005-05-11 18:04:31.473723221 +0400
+++ linux-2.6.12-rc3-mm3-vs/fs/reiser4/plugin/item/tail.c 2005-05-11 18:04:31.500725182 +0400
@@ -478,11 +478,6 @@ tail_balance_dirty_pages(struct address_
}
if (!reiser4_is_set(inode->i_sb, REISER4_ATOMIC_WRITE)) {
- /* FIXME-VS: this is temporary: the problem is that bdp takes
- inodes from sb's dirty list and it looks like nobody puts
- there inodes of files which are built of tails */
- move_inode_out_from_sync_inodes_loop(mapping);
-
uf_info = unix_file_inode_data(inode);
excl = unix_file_inode_data(inode)->exclusive_use;
if (excl)
diff -puN fs/reiser4/entd.c~reiser4-update-3 fs/reiser4/entd.c
--- linux-2.6.12-rc3-mm3/fs/reiser4/entd.c~reiser4-update-3 2005-05-11 18:04:42.609532006 +0400
+++ linux-2.6.12-rc3-mm3-vs/fs/reiser4/entd.c 2005-05-11 18:25:36.920631675 +0400
@@ -242,14 +242,6 @@ static void kick_entd(entd_context * ent
kcond_signal(&ent->wait);
}
return ret;
}
@@ -1787,7 +1785,7 @@ try_commit_txnh(commit_data *cd)
/* Called to commit a transaction handle. This decrements the atom's number of open
handles and if it is the last handle to commit and the atom should commit, initiates
atom commit. if commit does not fail, return number of written blocks */
-static long
+static int
commit_txnh(txn_handle * txnh)
{
commit_data cd;
diff -puN fs/reiser4/txnmgr.h~reiser4-update-3 fs/reiser4/txnmgr.h
--- linux-2.6.12-rc3-mm3/fs/reiser4/txnmgr.h~reiser4-update-3 2005-05-11 18:21:01.254610260 +0400
+++ linux-2.6.12-rc3-mm3-vs/fs/reiser4/txnmgr.h 2005-05-11 18:21:35.080066978 +0400
@@ -459,7 +459,7 @@ extern int txnmgr_done(txn_mgr * mgr);
extern int txn_reserve(int reserved);
extern void txn_begin(reiser4_context * context);
-extern long txn_end(reiser4_context * context);
+extern int txn_end(reiser4_context * context);