From f98de6c88bbea09960f6019c7ad92a03a2b44913 Mon Sep 17 00:00:00 2001 From: adilger Date: Mon, 9 Feb 2004 23:07:20 +0000 Subject: [PATCH] Fix truncate-vs-write corruption - truncate wasn't marking the last partial page dirty in any lists (from 1.0.4). b=2366 --- lustre/ChangeLog | 2 +- .../patches/ext3-truncate-buffer-head.patch | 10 +++ lustre/kernel_patches/series/bproc-2.4.20-hp-pnnl | 1 + lustre/kernel_patches/series/chaos-2.4.18 | 1 + lustre/kernel_patches/series/chaos-2.4.18-pdirops | 1 + lustre/kernel_patches/series/chaos-2.4.20 | 27 -------- lustre/kernel_patches/series/chaos-2.4.21 | 1 + lustre/kernel_patches/series/hp-pnnl-2.4.20 | 1 + lustre/kernel_patches/series/rh-2.4.20 | 1 + lustre/kernel_patches/series/rh-2.4.22 | 1 + lustre/kernel_patches/series/suse-2.4.19 | 1 + lustre/kernel_patches/series/suse-2.4.21 | 1 + lustre/kernel_patches/series/suse-2.4.21-2 | 1 + lustre/kernel_patches/series/vanilla-2.4.19-pre1 | 1 + lustre/kernel_patches/series/vanilla-2.4.20 | 1 + lustre/kernel_patches/series/vanilla-2.4.22 | 1 + lustre/kernel_patches/series/vanilla-2.4.24 | 1 + lustre/obdfilter/filter_io_24.c | 10 ++- lustre/obdfilter/filter_io_26.c | 72 +++++++++++----------- 19 files changed, 71 insertions(+), 64 deletions(-) create mode 100644 lustre/kernel_patches/patches/ext3-truncate-buffer-head.patch delete mode 100644 lustre/kernel_patches/series/chaos-2.4.20 diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 8999bec..03a084a 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -15,9 +15,9 @@ tbd Cluster File Systems, Inc. 2004-02-06 Cluster File Systems, Inc. * version 1.0.4 * kernel patches + - fix truncated write corruption (2366) - fix for failed assertion in iopen_connect_dentry (1792,2517) - 2004-01-27 Cluster File Systems, Inc. * version 1.0.3 * kernel patches diff --git a/lustre/kernel_patches/patches/ext3-truncate-buffer-head.patch b/lustre/kernel_patches/patches/ext3-truncate-buffer-head.patch new file mode 100644 index 0000000..f6be984 --- /dev/null +++ b/lustre/kernel_patches/patches/ext3-truncate-buffer-head.patch @@ -0,0 +1,10 @@ +--- lum/fs/ext3/inode.c~ 2004-01-30 16:47:12.000000000 -0800 ++++ lum/fs/ext3/inode.c 2004-01-30 16:46:14.000000000 -0800 +@@ -1485,6 +1485,7 @@ + if (ext3_should_order_data(inode)) + err = ext3_journal_dirty_data(handle, bh, 0); + __mark_buffer_dirty(bh); ++ buffer_insert_inode_data_queue(bh, inode); + } + + unlock: diff --git a/lustre/kernel_patches/series/bproc-2.4.20-hp-pnnl b/lustre/kernel_patches/series/bproc-2.4.20-hp-pnnl index 51e4937..41437b8 100644 --- a/lustre/kernel_patches/series/bproc-2.4.20-hp-pnnl +++ b/lustre/kernel_patches/series/bproc-2.4.20-hp-pnnl @@ -34,3 +34,4 @@ jbd-get_write_access.patch nfs_export_kernel-2.4.20-hp.patch ext3-ea-in-inode-2.4.20.patch bproc-patch-2.4.20 +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/chaos-2.4.18 b/lustre/kernel_patches/series/chaos-2.4.18 index ec539c5..9bd5681 100644 --- a/lustre/kernel_patches/series/chaos-2.4.18 +++ b/lustre/kernel_patches/series/chaos-2.4.18 @@ -35,3 +35,4 @@ gfp_memalloc-2.4.18-chaos.patch ext3-xattr-ptr-arith-fix.patch kernel_text_address-2.4.18-chaos.patch procfs-ndynamic-2.4.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/chaos-2.4.18-pdirops b/lustre/kernel_patches/series/chaos-2.4.18-pdirops index 09b8592..c180a5b 100644 --- a/lustre/kernel_patches/series/chaos-2.4.18-pdirops +++ b/lustre/kernel_patches/series/chaos-2.4.18-pdirops @@ -32,3 +32,4 @@ ext3-pdirops-2.4.18-chaos.patch ext3-extents-2.4.18-chaos-pdirops.patch nfs_export_kernel-2.4.18.patch ext3-raw-lookup-pdirops.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/chaos-2.4.20 b/lustre/kernel_patches/series/chaos-2.4.20 deleted file mode 100644 index f7a209f..0000000 --- a/lustre/kernel_patches/series/chaos-2.4.20 +++ /dev/null @@ -1,27 +0,0 @@ -dev_read_only_2.4.20-rh.patch -exports_2.4.20-rh-hp.patch -kmem_cache_validate_2.4.20-rh.patch -lustre_version.patch -vfs_intent_2.4.20_chaos.patch -invalidate_show_2.4.20_chaos.patch -iod-rmap-exports-2.4.20.patch -export-truncate.patch -ext-2.4-patch-1-chaos.patch -ext-2.4-patch-2.patch -ext-2.4-patch-3.patch -ext-2.4-patch-4.patch -linux-2.4.20-xattr-0.8.54-chaos.patch -ext3-2.4.20-fixes.patch -ext3_orphan_lock-2.4.20-rh.patch -ext3_delete_thread_2.4.20_chaos.patch -ext3-noread-2.4.20.patch -extN-wantedi.patch -ext3-san-2.4.20.patch -ext3-map_inode_page.patch -ext3-error-export.patch -iopen-2.4.20.patch -tcp_zero_copy_2.4.20_chaos.patch -gpl_header-chaos-2.4.20.patch -add_page_private.patch -jbd-flushtime.patch -jbd-get_write_access.patch diff --git a/lustre/kernel_patches/series/chaos-2.4.21 b/lustre/kernel_patches/series/chaos-2.4.21 index 7a406fc..8e20c51 100644 --- a/lustre/kernel_patches/series/chaos-2.4.21 +++ b/lustre/kernel_patches/series/chaos-2.4.21 @@ -31,3 +31,4 @@ gfp_memalloc-2.4.21-chaos.patch ext3-xattr-ptr-arith-fix.patch kernel_text_address-2.4.18-chaos.patch pagecache-lock-2.4.21-chaos.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/hp-pnnl-2.4.20 b/lustre/kernel_patches/series/hp-pnnl-2.4.20 index bcaa036..e3c5a62 100644 --- a/lustre/kernel_patches/series/hp-pnnl-2.4.20 +++ b/lustre/kernel_patches/series/hp-pnnl-2.4.20 @@ -38,3 +38,4 @@ ext3-trusted_ea-2.4.20.patch gfp_memalloc-2.4.22.patch ext3-xattr-ptr-arith-fix.patch procfs-ndynamic-2.4.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/rh-2.4.20 b/lustre/kernel_patches/series/rh-2.4.20 index 9fb8c0f..d9c6f39 100644 --- a/lustre/kernel_patches/series/rh-2.4.20 +++ b/lustre/kernel_patches/series/rh-2.4.20 @@ -43,3 +43,4 @@ kernel_text_address-2.4.20-rh.patch gfp_memalloc-2.4.20-rh.patch ext3-xattr-ptr-arith-fix.patch procfs-ndynamic-2.4.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/rh-2.4.22 b/lustre/kernel_patches/series/rh-2.4.22 index 2b01f1f..2d8c431 100644 --- a/lustre/kernel_patches/series/rh-2.4.22 +++ b/lustre/kernel_patches/series/rh-2.4.22 @@ -29,3 +29,4 @@ gfp_memalloc-2.4.22.patch ext3-xattr-ptr-arith-fix.patch procfs-ndynamic-2.4.patch kernel_text_address-2.4.18-chaos.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/suse-2.4.19 b/lustre/kernel_patches/series/suse-2.4.19 index 4365c39..9905491 100644 --- a/lustre/kernel_patches/series/suse-2.4.19 +++ b/lustre/kernel_patches/series/suse-2.4.19 @@ -33,3 +33,4 @@ jbd-get_write_access.patch ext3-ea-in-inode-2.4.20.patch listman-2.4.20.patch ext3-trusted_ea-2.4.20.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/suse-2.4.21 b/lustre/kernel_patches/series/suse-2.4.21 index b8da362..481ed7d 100644 --- a/lustre/kernel_patches/series/suse-2.4.21 +++ b/lustre/kernel_patches/series/suse-2.4.21 @@ -30,3 +30,4 @@ ext3-trusted_ea-2.4.20.patch gfp_memalloc-2.4.22.patch ext3-xattr-ptr-arith-fix.patch procfs-ndynamic-2.4.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/suse-2.4.21-2 b/lustre/kernel_patches/series/suse-2.4.21-2 index c6bdaa0..3593126 100644 --- a/lustre/kernel_patches/series/suse-2.4.21-2 +++ b/lustre/kernel_patches/series/suse-2.4.21-2 @@ -29,3 +29,4 @@ gfp_memalloc-2.4.24.patch ext3-xattr-ptr-arith-fix.patch kernel_text_address-2.4.20-vanilla.patch procfs-ndynamic-2.4.21-suse2.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/vanilla-2.4.19-pre1 b/lustre/kernel_patches/series/vanilla-2.4.19-pre1 index e3124b7..19c6974 100644 --- a/lustre/kernel_patches/series/vanilla-2.4.19-pre1 +++ b/lustre/kernel_patches/series/vanilla-2.4.19-pre1 @@ -45,3 +45,4 @@ resched-2.4.19-pre1.patch ext3-xattr-ptr-arith-fix.patch gfp_memalloc-2.4.22.patch vmalloc_to_page-2.4.19-pre1.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/vanilla-2.4.20 b/lustre/kernel_patches/series/vanilla-2.4.20 index 51849bb..abb6bbe 100644 --- a/lustre/kernel_patches/series/vanilla-2.4.20 +++ b/lustre/kernel_patches/series/vanilla-2.4.20 @@ -51,3 +51,4 @@ ext3-xattr-ptr-arith-fix.patch gfp_memalloc-2.4.22.patch procfs-ndynamic-2.4.patch linux-2.4.20-tmpfs-xattr.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/vanilla-2.4.22 b/lustre/kernel_patches/series/vanilla-2.4.22 index 92f76eb..3d5bb6d 100644 --- a/lustre/kernel_patches/series/vanilla-2.4.22 +++ b/lustre/kernel_patches/series/vanilla-2.4.22 @@ -32,3 +32,4 @@ gfp_memalloc-2.4.22.patch ext3-xattr-ptr-arith-fix.patch 3.5G-address-space-2.4.22-vanilla.patch procfs-ndynamic-2.4.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/kernel_patches/series/vanilla-2.4.24 b/lustre/kernel_patches/series/vanilla-2.4.24 index b788159..220d3bc 100644 --- a/lustre/kernel_patches/series/vanilla-2.4.24 +++ b/lustre/kernel_patches/series/vanilla-2.4.24 @@ -34,3 +34,4 @@ gfp_memalloc-2.4.24.patch ext3-xattr-ptr-arith-fix.patch 3.5G-address-space-2.4.22-vanilla.patch procfs-ndynamic-2.4.patch +ext3-truncate-buffer-head.patch diff --git a/lustre/obdfilter/filter_io_24.c b/lustre/obdfilter/filter_io_24.c index 84d536b..32adb9f 100644 --- a/lustre/obdfilter/filter_io_24.c +++ b/lustre/obdfilter/filter_io_24.c @@ -124,7 +124,7 @@ static int filter_direct_io(int rw, struct dentry *dchild, struct kiobuf *iobuf, } up(&exp->exp_obd->u.filter.fo_alloc_lock); - filter_tally_write(&obd->u.filter, iobuf->maplist, iobuf->nr_pages, + filter_tally_write(&obd->u.filter, iobuf->maplist, iobuf->nr_pages, iobuf->blocks, blocks_per_page); if (attr->ia_size > inode->i_size) @@ -149,6 +149,14 @@ static int filter_direct_io(int rw, struct dentry *dchild, struct kiobuf *iobuf, check_pending_bhs(iobuf->blocks, iobuf->nr_pages, inode->i_dev, 1 << inode->i_blkbits); + rc = filemap_fdatasync(inode->i_mapping); + if (rc == 0) + rc = fsync_inode_data_buffers(inode); + if (rc == 0) + rc = filemap_fdatawait(inode->i_mapping); + if (rc < 0) + GOTO(cleanup, rc); + rc = brw_kiovec(WRITE, 1, &iobuf, inode->i_dev, iobuf->blocks, 1 << inode->i_blkbits); CDEBUG(D_INFO, "tried to write %d pages, rc = %d\n", diff --git a/lustre/obdfilter/filter_io_26.c b/lustre/obdfilter/filter_io_26.c index cc0007f..b312f8b1 100644 --- a/lustre/obdfilter/filter_io_26.c +++ b/lustre/obdfilter/filter_io_26.c @@ -46,8 +46,8 @@ struct dio_request { atomic_t numreqs; /* number of reqs being processed */ struct bio *bio_list; /* list of completed bios */ wait_queue_head_t wait; - int created[MAX_BLOCKS_PER_PAGE]; - unsigned long blocks[MAX_BLOCKS_PER_PAGE]; + int created[MAX_BLOCKS_PER_PAGE]; + unsigned long blocks[MAX_BLOCKS_PER_PAGE]; spinlock_t lock; }; @@ -68,13 +68,13 @@ static int dio_complete_routine(struct bio *bio, unsigned int done, int error) static int can_be_merged(struct bio *bio, sector_t sector) { - int size; - - if (!bio) - return 0; - - size = bio->bi_size >> 9; - return bio->bi_sector + size == sector ? 1 : 0; + int size; + + if (!bio) + return 0; + + size = bio->bi_size >> 9; + return bio->bi_sector + size == sector ? 1 : 0; } int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount, @@ -89,7 +89,7 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount, struct inode *inode = NULL; int rc = 0, i, k, cleanup_phase = 0, err; unsigned long now = jiffies; /* DEBUGGING OST TIMEOUTS */ - int blocks_per_page; + int blocks_per_page; struct dio_request *dreq; struct bio *bio = NULL; ENTRY; @@ -99,7 +99,7 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount, inode = res->dentry->d_inode; blocks_per_page = PAGE_SIZE >> inode->i_blkbits; - LASSERT(blocks_per_page <= MAX_BLOCKS_PER_PAGE); + LASSERT(blocks_per_page <= MAX_BLOCKS_PER_PAGE); OBD_ALLOC(dreq, sizeof(*dreq)); if (dreq == NULL) @@ -114,7 +114,7 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount, fso.fso_bufcnt = obj->ioo_bufcnt; push_ctxt(&saved, &obd->obd_ctxt, NULL); - cleanup_phase = 2; + cleanup_phase = 2; oti->oti_handle = fsfilt_brw_start(obd, objcount, &fso, niocount, oti); if (IS_ERR(oti->oti_handle)) { @@ -130,37 +130,37 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount, for (i = 0, lnb = res; i < obj->ioo_bufcnt; i++, lnb++) { loff_t this_size; - sector_t sector; - int offs; + sector_t sector; + int offs; - /* get block number for next page */ + /* get block number for next page */ rc = ext3_map_inode_page(inode, lnb->page, dreq->blocks, dreq->created, 1); if (rc) GOTO(cleanup, rc); - for (k = 0; k < blocks_per_page; k++) { - sector = dreq->blocks[k] * (inode->i_sb->s_blocksize >> 9); - offs = k * inode->i_sb->s_blocksize; + for (k = 0; k < blocks_per_page; k++) { + sector = dreq->blocks[k] *(inode->i_sb->s_blocksize>>9); + offs = k * inode->i_sb->s_blocksize; - if (!bio || !can_be_merged(bio, sector) || - !bio_add_page(bio, lnb->page, lnb->len, offs)) { - if (bio) { + if (!bio || !can_be_merged(bio, sector) || + !bio_add_page(bio, lnb->page, lnb->len, offs)) { + if (bio) { atomic_inc(&dreq->numreqs); - submit_bio(WRITE, bio); - bio = NULL; - } - /* allocate new bio */ - bio = bio_alloc(GFP_NOIO, obj->ioo_bufcnt); - bio->bi_bdev = inode->i_sb->s_bdev; - bio->bi_sector = sector; - bio->bi_end_io = dio_complete_routine; + submit_bio(WRITE, bio); + bio = NULL; + } + /* allocate new bio */ + bio = bio_alloc(GFP_NOIO, obj->ioo_bufcnt); + bio->bi_bdev = inode->i_sb->s_bdev; + bio->bi_sector = sector; + bio->bi_end_io = dio_complete_routine; bio->bi_private = dreq; - if (!bio_add_page(bio, lnb->page, lnb->len, 0)) - LBUG(); - } - } + if (!bio_add_page(bio, lnb->page, lnb->len, 0)) + LBUG(); + } + } /* We expect these pages to be in offset order, but we'll * be forgiving */ @@ -168,12 +168,14 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount, if (this_size > iattr.ia_size) iattr.ia_size = this_size; } - if (bio) { + +#warning This probably needs filemap_fdatasync() like filter_io_24 (bug 2366) + if (bio) { atomic_inc(&dreq->numreqs); submit_bio(WRITE, bio); } - /* time to wait for I/O completion */ + /* time to wait for I/O completion */ wait_event(dreq->wait, atomic_read(&dreq->numreqs) == 0); /* free all bios */ -- 1.8.3.1