- 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);
-
- move_inode_out_from_sync_inodes_loop(mapping);
+ 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;
+ }
+ }
+ }
+
return ret;
}
/* 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/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 19:56:10.000000000 +0400
+++ linux-2.6.12-rc3-mm3-root/fs/reiser4/entd.c 2005-05-11 19:56:40.000000000 +0400
@@ -242,14 +242,6 @@ static void kick_entd(entd_context * ent
kcond_signal(&ent->wait);
}
-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 19:56:10.000000000 +0400
+++ linux-2.6.12-rc3-mm3-root/fs/reiser4/flush.h 2005-05-11 19:56:10.000000000 +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/plugin/file/file.c~reiser4-update-3 fs/reiser4/plugin/file/file.c
--- linux-2.6.12-rc3-mm3/fs/reiser4/plugin/file/file.c~reiser4-update-3 2005-05-11 19:56:10.000000000 +0400
+++ linux-2.6.12-rc3-mm3-root/fs/reiser4/plugin/file/file.c 2005-05-11 19:56:10.000000000 +0400
@@ -938,9 +938,7 @@ capturepage_unix_file(struct page * page
static void
redirty_inode(struct inode *inode)
{
- spin_lock(&inode_lock);
- inode->i_state |= I_DIRTY;
- spin_unlock(&inode_lock);
+ __mark_inode_dirty(inode, I_DIRTY_PAGES);
}
-
-#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 +1344,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 +1370,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);
@@ -1403,10 +1382,6 @@ capture_unix_file(struct inode *inode, s
redirty_inode(inode);
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/txnmgr.c~reiser4-update-3 fs/reiser4/txnmgr.c
--- linux-2.6.12-rc3-mm3/fs/reiser4/txnmgr.c~reiser4-update-3 2005-05-11 19:56:10.000000000 +0400
+++ linux-2.6.12-rc3-mm3-root/fs/reiser4/txnmgr.c 2005-05-11 19:56:10.000000000 +0400
@@ -245,7 +245,7 @@ year old --- define all technical terms
static void atom_free(txn_atom * atom);
-static long commit_txnh(txn_handle * txnh);
+static int commit_txnh(txn_handle * txnh);
- ret1 = txn_end(ctx);
- assert("vs-1692", ret1 == 0);
- if (ret1 > 0)
- *nr_submitted += ret1;
- txn_begin(ctx);
+ if (*nr_submitted > wbc->nr_to_write)
+ warning("", "asked for %ld, written %ld\n", wbc->nr_to_write, *nr_submitted);
+ txn_restart(ctx);
return ret;
}
@@ -1787,7 +1784,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 19:56:10.000000000 +0400
+++ linux-2.6.12-rc3-mm3-root/fs/reiser4/txnmgr.h 2005-05-11 19:56:10.000000000 +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);
extern void txn_restart(reiser4_context * context);
extern void txn_restart_current(void);
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 19:56:10.000000000 +0400
+++ linux-2.6.12-rc3-mm3-root/fs/reiser4/vfs_ops.c 2005-05-11 19:56:10.000000000 +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);