From patchwork Fri May 11 06:30:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10393347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E19446053A for ; Fri, 11 May 2018 06:30:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F238928DDB for ; Fri, 11 May 2018 06:30:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6BCB28DDA; Fri, 11 May 2018 06:30:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C0EA28DDF for ; Fri, 11 May 2018 06:30:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752504AbeEKGam (ORCPT ); Fri, 11 May 2018 02:30:42 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:37767 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752294AbeEKGa3 (ORCPT ); Fri, 11 May 2018 02:30:29 -0400 Received: by mail-pl0-f65.google.com with SMTP id w19-v6so101094plq.4 for ; Thu, 10 May 2018 23:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=XBVoyCxqkTa4WRXXznMXQtXD3OsFMEflghxNkw1gdYg=; b=PJFCWcz2V5/liOZ86o3wpMg9QFdrBaxrZkxwOmXbCm6vH3DmBtCA0gMH3H9wbl4C03 Y1TKmNibrw4G4+ZI7I6YdwmK4DPiKwKeCJDGgt9CpMeKTTv/QtiH/cX2lxlsNr36SxAG dOT/wA1lez9OgBnReyE33aBLAGkJgSmh+UmbDk1HKDvpIiwbaSyJ9J8wtzARMdbrUXfF wQ4QTSWuDAiv/42Ozl5ODRFcaGzUHOMnc0WIef+QOSNsa+CNXpzY3LGM1+08zb3rM0XY wO9PcTKrw81r48YgXz3Uik5MGoqix3nFy6/l9c6CSVTv9s1/XaKmjiD1D19g18De9aRd NxFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=XBVoyCxqkTa4WRXXznMXQtXD3OsFMEflghxNkw1gdYg=; b=hNiZR7cmu8pmyyAd3MfcvP2ceio21ctm2SycvL+HcCS1YrHrqkunLboVOIZOZPf4Gg xrtz7hviadR7X5WuNJ6H6LPWfHAOGwMldpOSllbM9KhUUXD9piIcYX2TreQNMDGNYxOw LyyuuN0Wql9yGtxIzsfWt53KNO0jsJxv/UYDI5IGkiFHQ7mzTv1dpfuN41k2T3WhtMgF c9HrbzkgtBG5qCTu8teswk2vSfdXizlFe/7Plq02oL18ti9wYLj1/7qEzitvgkKopRwm F/5jLndHa6hCj1sFvR/bjf53eceBWPbK1zAh4gJSHKeiEuRiQ8dAvZTLcdF9bPZEOynG 7tRQ== X-Gm-Message-State: ALKqPwdzvx95ECfRHT6R0u351k/xDzSbShl9G1jlo26VK4/cCifnOKmf S7FErmUxBQAz5mBi37DchZ/T1g== X-Google-Smtp-Source: AB8JxZqAEvm/LQa2d0pUFcAFYU3xJz8lC+37Fxq98t7iu5vIee628kRRXmZP0I4a/rfZISfWO26O/w== X-Received: by 2002:a17:902:369:: with SMTP id 96-v6mr4372095pld.64.1526020228478; Thu, 10 May 2018 23:30:28 -0700 (PDT) Received: from vader.hsd1.wa.comcast.net ([2601:602:8800:a9a9:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id a11-v6sm4481982pgn.64.2018.05.10.23.30.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 May 2018 23:30:27 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: kernel-team@fb.com Subject: [PATCH 3/3] Btrfs: stop abusing current->journal_info in btrfs_direct_IO() Date: Thu, 10 May 2018 23:30:12 -0700 Message-Id: <23547c262a1b96459496e6e4073f1ef04f52feca.1525933432.git.osandov@fb.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval Now that we can pass around the struct btrfs_dio_data through the different callbacks generically, we don't need to shove it in current->journal_info. Signed-off-by: Omar Sandoval --- fs/btrfs/inode.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 46e3d366df8b..3673c0420509 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7574,7 +7574,7 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock, struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct extent_map *em; struct extent_state *cached_state = NULL; - struct btrfs_dio_data *dio_data = NULL; + struct btrfs_dio_data *dio_data = bh_result->b_private; u64 start = iblock << inode->i_blkbits; u64 lockstart, lockend; u64 len = bh_result->b_size; @@ -7589,25 +7589,13 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock, lockstart = start; lockend = start + len - 1; - if (current->journal_info) { - /* - * Need to pull our outstanding extents and set journal_info to NULL so - * that anything that needs to check if there's a transaction doesn't get - * confused. - */ - dio_data = current->journal_info; - current->journal_info = NULL; - } - /* * If this errors out it's because we couldn't invalidate pagecache for * this range and we need to fallback to buffered. */ if (lock_extent_direct(inode, lockstart, lockend, &cached_state, - create)) { - ret = -ENOTBLK; - goto err; - } + create)) + return -ENOTBLK; em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, start, len, 0); if (IS_ERR(em)) { @@ -7732,7 +7720,6 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock, WARN_ON(dio_data->reserve < len); dio_data->reserve -= len; dio_data->unsubmitted_oe_range_end = start + len; - current->journal_info = dio_data; } /* @@ -7755,9 +7742,6 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock, unlock_err: clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend, unlock_bits, 1, 0, &cached_state); -err: - if (dio_data) - current->journal_info = dio_data; return ret; } @@ -8460,7 +8444,7 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode, * time by btrfs_direct_IO(). */ if (write) { - struct btrfs_dio_data *dio_data = current->journal_info; + struct btrfs_dio_data *dio_data = private; dio_data->unsubmitted_oe_range_end = dip->logical_offset + dip->bytes; @@ -8602,13 +8586,11 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) /* * We need to know how many extents we reserved so that we can * do the accounting properly if we go over the number we - * originally calculated. Abuse current->journal_info for this. + * originally calculated. */ - dio_data.reserve = round_up(count, - fs_info->sectorsize); + dio_data.reserve = round_up(count, fs_info->sectorsize); dio_data.unsubmitted_oe_range_start = (u64)offset; dio_data.unsubmitted_oe_range_end = (u64)offset; - current->journal_info = &dio_data; down_read(&BTRFS_I(inode)->dio_sem); } else if (test_bit(BTRFS_INODE_READDIO_NEED_LOCK, &BTRFS_I(inode)->runtime_flags)) { @@ -8620,10 +8602,9 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) ret = __blockdev_direct_IO(iocb, inode, fs_info->fs_devices->latest_bdev, iter, btrfs_get_blocks_direct, NULL, - btrfs_submit_direct, flags, NULL); + btrfs_submit_direct, flags, &dio_data); if (iov_iter_rw(iter) == WRITE) { up_read(&BTRFS_I(inode)->dio_sem); - current->journal_info = NULL; if (ret < 0 && ret != -EIOCBQUEUED) { if (dio_data.reserve) btrfs_delalloc_release_space(inode, data_reserved,