From patchwork Tue Aug 28 00:03:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10577679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8646B15A7 for ; Tue, 28 Aug 2018 00:03:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C8E029DCA for ; Tue, 28 Aug 2018 00:03:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7037F29DF6; Tue, 28 Aug 2018 00:03:42 +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=ham 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 BB08A29DCA for ; Tue, 28 Aug 2018 00:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727421AbeH1Dwe (ORCPT ); Mon, 27 Aug 2018 23:52:34 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:32903 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727397AbeH1Dwa (ORCPT ); Mon, 27 Aug 2018 23:52:30 -0400 Received: by mail-pl1-f194.google.com with SMTP id 60-v6so326582ple.0 for ; Mon, 27 Aug 2018 17:03:36 -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; bh=Ld2JF7mGptEylDJWLFnHx+GGdAEzcImBSqrl12OPJPk=; b=2IP1vdH4Dr9XMz4WzDutNcGDtkk1TcwXI/2tHlXtlNPckMFmPuWTgX4+eYVIDp0TT3 Hcs8oNLJTeK0TqFwkRg7O236I7BheBexo0B6S/hqX+e2aSf/X9X5FGphd3xmnmxys4Xk hfUWd4/Z70Sj+0k1gNUr3NwZY0PwbFOwMKoFonW1Upzlt/0EfGSqAP9TXtA+WT4DPyUR EE9IkD558CGlDA35qBNLU3oPYNQF/8Bra53JTLRnxl/mxjaDHcH0U0OMZipbq53iZwhM jFv8Cx/2Z9OX4hes8alHtlVvuIoJty6cEynzs2vMpu8MhurLBL4qfY5IOEikzYJmbWEK UVyA== 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; bh=Ld2JF7mGptEylDJWLFnHx+GGdAEzcImBSqrl12OPJPk=; b=ThPDgoOBx7cp1E8MxjhAeN33e2z5NWeneDgaz/fpX1lYdlw4ui19Kop9wI+xokgyAb JQ4uMPQAB0BWEgAp8d1d9fA7cFYmR6aedl3vwakAZH4YBPdfZDibcl8BzGjd+pmDcAej 6Q2KnRtnwIBA+57kuhgBTif4Jor1hr/oR/264Dw76VZeQ0pQ5a8IVg7ixgpWNzpEtF5b YQiM7QsEvXradyCDPJWVALTBuIAE0XcsGOLuDjCOk7tY6YcFGN39ZiCujHOEv2iCQ6vp 2ZySDUnHt0wg0ruRu+pgtY+iO6vTA94pyibDLFZV+MtkFOIYTnd30iWCV23mf/jLWNcz 2wMQ== X-Gm-Message-State: APzg51Bh7khUM2MZOiAq+Df4RHWQ12qFojd5fdBIY+aa2kiPXuaQ5pTm NyrBZqnVP/SYyK39Ap1mPfp3kngjths= X-Google-Smtp-Source: ANB0Vdbmq0BUZItmL/U8HO8I9np6q/ZMPlGP3zP+YelLXXfQXJknYvuLvSVMy6oSFlkXZT2EsUUEOA== X-Received: by 2002:a17:902:981:: with SMTP id 1-v6mr15309125pln.229.1535414615862; Mon, 27 Aug 2018 17:03:35 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::7:5f0c]) by smtp.gmail.com with ESMTPSA id z22-v6sm455315pgc.67.2018.08.27.17.03.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 17:03:34 -0700 (PDT) From: Omar Sandoval To: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, Al Viro Cc: David Sterba , kernel-team@fb.com Subject: [RFC PATCH v2 6/6] Btrfs: stop abusing current->journal_info in btrfs_direct_IO() Date: Mon, 27 Aug 2018 17:03:19 -0700 Message-Id: X-Mailer: git-send-email 2.18.0 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 | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 6efa6a6e3e20..38a41e9d6e93 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7654,7 +7654,6 @@ static int btrfs_get_blocks_direct_write(struct extent_map **map, WARN_ON(dio_data->reserve < len); dio_data->reserve -= len; dio_data->unsubmitted_oe_range_end = start + len; - current->journal_info = dio_data; out: return ret; } @@ -7666,7 +7665,7 @@ static int btrfs_get_blocks_direct(struct kiocb *iocb, struct inode *inode, 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 = iocb->private; u64 start = iblock << inode->i_blkbits; u64 lockstart, lockend; u64 len = bh_result->b_size; @@ -7681,25 +7680,13 @@ static int btrfs_get_blocks_direct(struct kiocb *iocb, struct inode *inode, 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)) { @@ -7767,9 +7754,6 @@ static int btrfs_get_blocks_direct(struct kiocb *iocb, struct inode *inode, 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; } @@ -8470,7 +8454,7 @@ static void btrfs_submit_direct(struct kiocb *iocb, struct bio *dio_bio, * time by btrfs_direct_IO(). */ if (write) { - struct btrfs_dio_data *dio_data = current->journal_info; + struct btrfs_dio_data *dio_data = iocb->private; dio_data->unsubmitted_oe_range_end = dip->logical_offset + dip->bytes; @@ -8612,13 +8596,13 @@ 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.unsubmitted_oe_range_start = (u64)offset; dio_data.unsubmitted_oe_range_end = (u64)offset; - current->journal_info = &dio_data; + iocb->private = &dio_data; down_read(&BTRFS_I(inode)->dio_sem); } else if (test_bit(BTRFS_INODE_READDIO_NEED_LOCK, &BTRFS_I(inode)->runtime_flags)) { @@ -8633,7 +8617,6 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) btrfs_submit_direct, flags); 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,