Andrew, thank you for this help. Andrew Morton wrote:Well, in my case I force write-back from prepare_write _only_ when the page is clean, because if it is dirty, it was (pessimistically) accounted earlier already and changing dirty page does not change anything on the media. So I call writeback only for _new_ pages, which are always clean. I use PagePrivate() flag to flag pages as dirty, and unflag them in writepage(). I need to keep my own accounting of number of dirty pages at any point of time. I found that I cannot use PageDirty() flag because it is cleaned before my ->writepage is called, so I cannot decrement my dirty_pg_counter, and I'd have to muck with radix tree's tags which I do not really like to do, thus I just use the private flag. So in writepage() i only call writeback if PagePrivate() is unset, which guarantees me that the page is clean, I presume. So for my purposes the patch below _looks_ ok. I'm saying "looks" because I tested it just a little. Ok, thank you! I (naively) thought i_mutex is locked in ->writepage. But now I see that pdflush does not lock it, readahead calls ->readpage without i_mutex too. They just lock the page. I see, thanks. There is also i_size and i_size_write() and i_size_read(). My understanding is that i_size may be changed without something (i_mutex or I_LOCK) locked, thus these helpers. i_size is read/written without them in many places, though, so the relation of these i_size protection helpers to i_mutex/I_LOCK is unclean for me. Ideally, it would be nice to teach lockdep to monitor I_LOCK vs i_mutex. Below it the patch which seems to give me what I need. Just for reference. ========================= Subject: [PATCH] VFS: introduce writeback_inodes_sb() Let file systems to writeback their pages and inodes when needed. Note, it cannot be called if one of the dirty pages is locked by the caller, otherwise it'll deadlock. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> --- fs/fs-writeback.c | 8 ++++++++ include/linux/writeback.h | 1 + 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index a4b142a..17c8aaa 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -486,6 +486,14 @@ void sync_inodes_sb(struct super_block *sb, int wait) spin_unlock(&inode_lock); } +void writeback_inodes_sb(struct super_block *sb, struct writeback_control *wbc) +{ + spin_lock(&inode_lock); + sync_sb_inodes(sb, wbc); + spin_unlock(&inode_lock); +} +EXPORT_SYMBOL_GPL(writeback_inodes_sb); + /* * Rather lame livelock avoidance. */ diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 4ef4d22..e20cd12 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -72,6 +72,7 @@ void writeback_inodes(struct writeback_control *wbc); void wake_up_inode(struct inode *inode); int inode_wait(void *); void sync_inodes_sb(struct super_block *, int wait); +void writeback_inodes_sb(struct super_block *sb, struct writeback_control *wbc); void sync_inodes(int wait); /* writeback.h requires fs.h; it, too, is not included from here. */ -- 1.5.0.6 -- Best Regards, Artem Bityutskiy (Артём Битюцкий) -
| Kok, Auke | Re: -mm merge plans for 2.6.23 - ioat/dma engine |
| Jeff Garzik | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
| Matthew Garrett | [PATCH] Remove process freezer from suspend to RAM pathway |
| Gerrit Renker | [PATCH 15/37] dccp: Set per-connection CCIDs via socket options |
| David Miller | [GIT]: Networking |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Jens Axboe | Re: [BUG] New Kernel Bugs |
git: | |
