diff options
author | Anton Altaparmakov <aia21@cantab.net> | 2005-09-08 21:25:48 +0100 |
---|---|---|
committer | Anton Altaparmakov <aia21@cantab.net> | 2005-09-08 21:25:48 +0100 |
commit | 8dcdebafb848415eae25924b00c4f0b9ec907da0 (patch) | |
tree | 5e7289dca23148d6b157817c6272c0fc3460f449 /fs/ntfs/aops.c | |
parent | 67bb103725e4cde322cb4ddb160a12933c5c7072 (diff) | |
download | linux-8dcdebafb848415eae25924b00c4f0b9ec907da0.tar.bz2 |
NTFS: Make ntfs_write_block() not instantiate sparse blocks if they are zero.
Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
Diffstat (limited to 'fs/ntfs/aops.c')
-rw-r--r-- | fs/ntfs/aops.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 78adad7a988d..f3ad36d8b8c9 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -670,6 +670,27 @@ lock_retry_remap: } /* It is a hole, need to instantiate it. */ if (lcn == LCN_HOLE) { + u8 *kaddr; + unsigned long *bpos, *bend; + + /* Check if the buffer is zero. */ + kaddr = kmap_atomic(page, KM_USER0); + bpos = (unsigned long *)(kaddr + bh_offset(bh)); + bend = (unsigned long *)((u8*)bpos + blocksize); + do { + if (unlikely(*bpos)) + break; + } while (likely(++bpos < bend)); + kunmap_atomic(kaddr, KM_USER0); + if (bpos == bend) { + /* + * Buffer is zero and sparse, no need to write + * it. + */ + bh->b_blocknr = -1; + clear_buffer_dirty(bh); + continue; + } // TODO: Instantiate the hole. // clear_buffer_new(bh); // unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr); |