Commit 98bc3149 authored by Josef Bacik's avatar Josef Bacik Committed by Chris Mason

Btrfs: don't allocate dip->csums when doing writes

When doing direct writes we store the checksums in the ordered sum stuff in the
ordered extent for writing them when the write completes, so we don't even use
the dip->csums array.  So if we're writing, don't bother allocating dip->csums
since we won't use it anyway.  Thanks,
Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
parent 4e69b598
...@@ -5944,6 +5944,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, ...@@ -5944,6 +5944,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
int nr_pages = 0; int nr_pages = 0;
u32 *csums = dip->csums; u32 *csums = dip->csums;
int ret = 0; int ret = 0;
int write = rw & REQ_WRITE;
bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev, start_sector, GFP_NOFS); bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev, start_sector, GFP_NOFS);
if (!bio) if (!bio)
...@@ -5980,7 +5981,8 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, ...@@ -5980,7 +5981,8 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
goto out_err; goto out_err;
} }
if (!skip_sum) /* Write's use the ordered csums */
if (!write && !skip_sum)
csums = csums + nr_pages; csums = csums + nr_pages;
start_sector += submit_len >> 9; start_sector += submit_len >> 9;
file_offset += submit_len; file_offset += submit_len;
...@@ -6048,7 +6050,8 @@ static void btrfs_submit_direct(int rw, struct bio *bio, struct inode *inode, ...@@ -6048,7 +6050,8 @@ static void btrfs_submit_direct(int rw, struct bio *bio, struct inode *inode,
} }
dip->csums = NULL; dip->csums = NULL;
if (!skip_sum) { /* Write's use the ordered csum stuff, so we don't need dip->csums */
if (!write && !skip_sum) {
dip->csums = kmalloc(sizeof(u32) * bio->bi_vcnt, GFP_NOFS); dip->csums = kmalloc(sizeof(u32) * bio->bi_vcnt, GFP_NOFS);
if (!dip->csums) { if (!dip->csums) {
kfree(dip); kfree(dip);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment