diff options
author | Fred Isaman <iisaman@citi.umich.edu> | 2011-07-30 20:52:55 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-07-31 12:18:17 -0400 |
commit | 31e6306a4046926b598484f1cacf69309382eac6 (patch) | |
tree | 3b71cc552cc00a37b3838c7eb0c7dd4d320fc71d /fs/nfs/blocklayout/blocklayout.c | |
parent | 650e2d39bd8f6b99f39b5009dbed9fbd3bb65e54 (diff) |
pnfsblock: note written INVAL areas for layoutcommit
Signed-off-by: Peng Tao <peng_tao@emc.com>
Signed-off-by: Fred Isaman <iisaman@citi.umich.edu>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Benny Halevy <bhalevy@tonian.com>
Signed-off-by: Jim Rees <rees@umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/blocklayout/blocklayout.c')
-rw-r--r-- | fs/nfs/blocklayout/blocklayout.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c index 2e373826db8..21efef7c2fd 100644 --- a/fs/nfs/blocklayout/blocklayout.c +++ b/fs/nfs/blocklayout/blocklayout.c | |||
@@ -329,6 +329,30 @@ out: | |||
329 | return PNFS_NOT_ATTEMPTED; | 329 | return PNFS_NOT_ATTEMPTED; |
330 | } | 330 | } |
331 | 331 | ||
332 | static void mark_extents_written(struct pnfs_block_layout *bl, | ||
333 | __u64 offset, __u32 count) | ||
334 | { | ||
335 | sector_t isect, end; | ||
336 | struct pnfs_block_extent *be; | ||
337 | |||
338 | dprintk("%s(%llu, %u)\n", __func__, offset, count); | ||
339 | if (count == 0) | ||
340 | return; | ||
341 | isect = (offset & (long)(PAGE_CACHE_MASK)) >> SECTOR_SHIFT; | ||
342 | end = (offset + count + PAGE_CACHE_SIZE - 1) & (long)(PAGE_CACHE_MASK); | ||
343 | end >>= SECTOR_SHIFT; | ||
344 | while (isect < end) { | ||
345 | sector_t len; | ||
346 | be = bl_find_get_extent(bl, isect, NULL); | ||
347 | BUG_ON(!be); /* FIXME */ | ||
348 | len = min(end, be->be_f_offset + be->be_length) - isect; | ||
349 | if (be->be_state == PNFS_BLOCK_INVALID_DATA) | ||
350 | bl_mark_for_commit(be, isect, len); /* What if fails? */ | ||
351 | isect += len; | ||
352 | bl_put_extent(be); | ||
353 | } | ||
354 | } | ||
355 | |||
332 | /* This is basically copied from mpage_end_io_read */ | 356 | /* This is basically copied from mpage_end_io_read */ |
333 | static void bl_end_io_write(struct bio *bio, int err) | 357 | static void bl_end_io_write(struct bio *bio, int err) |
334 | { | 358 | { |
@@ -355,6 +379,14 @@ static void bl_write_cleanup(struct work_struct *work) | |||
355 | dprintk("%s enter\n", __func__); | 379 | dprintk("%s enter\n", __func__); |
356 | task = container_of(work, struct rpc_task, u.tk_work); | 380 | task = container_of(work, struct rpc_task, u.tk_work); |
357 | wdata = container_of(task, struct nfs_write_data, task); | 381 | wdata = container_of(task, struct nfs_write_data, task); |
382 | if (!wdata->task.tk_status) { | ||
383 | /* Marks for LAYOUTCOMMIT */ | ||
384 | /* BUG - this should be called after each bio, not after | ||
385 | * all finish, unless have some way of storing success/failure | ||
386 | */ | ||
387 | mark_extents_written(BLK_LSEG2EXT(wdata->lseg), | ||
388 | wdata->args.offset, wdata->args.count); | ||
389 | } | ||
358 | pnfs_ld_write_done(wdata); | 390 | pnfs_ld_write_done(wdata); |
359 | } | 391 | } |
360 | 392 | ||