=========================================================================== linux/fs/xfs/linux/xfs_iomap.c =========================================================================== --- /usr/tmp/TmpDir.1845-0/linux/fs/xfs/linux/xfs_iomap.c_1.16 2003-11-07 14:32:02.000000000 +1100 +++ linux/fs/xfs/linux/xfs_iomap.c 2003-11-07 12:33:54.130183320 +1100 @@ -243,7 +243,7 @@ case 0: if (ip->i_delayed_blks) { xfs_iunlock(ip, XFS_ILOCK_EXCL); - fsync_inode_data_buffers(LINVFS_GET_IP(vp)); + filemap_fdatawrite(LINVFS_GET_IP(vp)->i_mapping); xfs_ilock(ip, XFS_ILOCK_EXCL); *fsynced = 1; } else { =========================================================================== linux/include/linux/fs.h =========================================================================== --- /usr/tmp/TmpDir.1845-0/linux/include/linux/fs.h_1.166 2003-11-07 14:32:02.000000000 +1100 +++ linux/include/linux/fs.h 2003-11-07 14:29:24.486609000 +1100 @@ -1292,6 +1292,7 @@ } extern int inode_has_buffers(struct inode *); extern int do_fdatasync(struct file *); +extern int filemap_fdatawrite(struct address_space *); extern int filemap_fdatasync(struct address_space *); extern int filemap_fdatawait(struct address_space *); extern void sync_supers(kdev_t dev, int wait); =========================================================================== linux/mm/filemap.c =========================================================================== --- /usr/tmp/TmpDir.1845-0/linux/mm/filemap.c_1.120 2003-11-07 14:32:02.000000000 +1100 +++ linux/mm/filemap.c 2003-11-07 14:27:52.920529160 +1100 @@ -546,6 +546,49 @@ EXPORT_SYMBOL(fail_writepage); /** + * filemap_fdatawrite - walk the list of dirty pages of the given address space + * and writepage() each unlocked page (does not wait on locked pages). + * + * @mapping: address space structure to write + * + */ +int filemap_fdatawrite(struct address_space * mapping) +{ + int ret = 0; + int (*writepage)(struct page *) = mapping->a_ops->writepage; + + spin_lock(&pagecache_lock); + + while (!list_empty(&mapping->dirty_pages)) { + struct page *page = list_entry(mapping->dirty_pages.prev, struct page, list); + + list_del(&page->list); + list_add(&page->list, &mapping->locked_pages); + + if (!PageDirty(page)) + continue; + + page_cache_get(page); + spin_unlock(&pagecache_lock); + + if (!TryLockPage(page)) { + if (PageDirty(page)) { + int err; + ClearPageDirty(page); + err = writepage(page); + if (err && !ret) + ret = err; + } else + UnlockPage(page); + } + page_cache_release(page); + spin_lock(&pagecache_lock); + } + spin_unlock(&pagecache_lock); + return ret; +} + +/** * filemap_fdatasync - walk the list of dirty pages of the given address space * and writepage() all of them. *