From patchwork Mon Dec 15 05:26:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 5490561 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5DB4B9F1D4 for ; Mon, 15 Dec 2014 05:29:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 885B0209E7 for ; Mon, 15 Dec 2014 05:29:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA3C5209E5 for ; Mon, 15 Dec 2014 05:29:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750974AbaLOF1l (ORCPT ); Mon, 15 Dec 2014 00:27:41 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:53933 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751213AbaLOF12 (ORCPT ); Mon, 15 Dec 2014 00:27:28 -0500 Received: by mail-pa0-f43.google.com with SMTP id kx10so11097383pab.16 for ; Sun, 14 Dec 2014 21:27:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=30+Y6n4gwSKTxAXY+ZEu8h2sXwKQOswqqmKqCT97k4g=; b=lc7AVRZY4L+k3yqoyM07qn4Q6n+5Aon9JVFZFoJFQn87PZxHgPbpyTczjPEERV7RSh lvYZTzzAEoJrBKFMKKUJJRNu7f9ntYyMub0OhGqoJbG5H0SsNErVY9fSU1PHbet/17zP uzPcx/BXN7c/YLz5U59g+3lX2G5C0BebvCvVj0ch6NNQeySRJd8VsoPESlgt4Ie+VV2l CHv9J7OaPL/We8fa4D31S9mSJbU5Q4hStTOQSNMboT2MOom+Fri0J8LQQt+9qiJD0wAq vpU6W6Q6tUH9lSrqQEiKIixdSdRDdilKmxaW2r4ylMqPoVTSSq/yM/A+ZmXUyhixzoT0 7eDA== X-Gm-Message-State: ALoCoQnjMy+QpF9yrBtye9zn9GOZqf5Wp7OQDVlWna6qeMY0JIxCs2ZZDewp5k9Vg0mJ6vMU6BqZ X-Received: by 10.68.137.101 with SMTP id qh5mr28650604pbb.13.1418621247683; Sun, 14 Dec 2014 21:27:27 -0800 (PST) Received: from mew.localdomain ([72.192.100.38]) by mx.google.com with ESMTPSA id f12sm7915174pdm.90.2014.12.14.21.27.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Dec 2014 21:27:27 -0800 (PST) From: Omar Sandoval To: Alexander Viro , Andrew Morton , Trond Myklebust , Christoph Hellwig , David Sterba , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Omar Sandoval Subject: [PATCH 2/8] swap: lock i_mutex for swap_writepage direct_IO Date: Sun, 14 Dec 2014 21:26:56 -0800 Message-Id: X-Mailer: git-send-email 2.1.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The generic write code locks i_mutex for a direct_IO. Swap-over-NFS doesn't grab the mutex because nfs_direct_IO doesn't expect i_mutex to be held, but most direct_IO implementations do. Signed-off-by: Omar Sandoval --- mm/page_io.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_io.c b/mm/page_io.c index 955db8b..1630ac0 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -263,6 +263,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, if (sis->flags & SWP_FILE) { struct kiocb kiocb; struct file *swap_file = sis->swap_file; + struct inode *inode = file_inode(swap_file); struct address_space *mapping = swap_file->f_mapping; struct bio_vec bv = { .bv_page = page, @@ -283,9 +284,11 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, set_page_writeback(page); unlock_page(page); + mutex_lock(&inode->i_mutex); ret = mapping->a_ops->direct_IO(ITER_BVEC | WRITE, &kiocb, &from, kiocb.ki_pos); + mutex_unlock(&inode->i_mutex); if (ret == PAGE_SIZE) { count_vm_event(PSWPOUT); ret = 0;