Received: by 10.213.65.68 with SMTP id h4csp697269imn; Fri, 6 Apr 2018 07:27:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/5G3VKFzJjf53GVrN7Wa8MdTIWPaHgmvbZHniT2RswA0KAufTK1sYGfFbYzG+1UEnHMjj+ X-Received: by 2002:a17:902:209:: with SMTP id 9-v6mr27021368plc.403.1523024840035; Fri, 06 Apr 2018 07:27:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523024839; cv=none; d=google.com; s=arc-20160816; b=o2ApfgeZFZUW9xEpW0sDX9yacZL8OBcK3mtsPByYHjA82kwNR7/QK1Y8PdapnB9c+n 1q4SptRL9McF0yAzYCS+NZdh7xrSJAAQGg0gZuT405Rk3+bfWpsyyIDOhVI21tMjqUY5 8TpSs7VwNjZq3xt+Tq3fGGbn2Jo9C817ytSCRTI5WRWMndZUHvXP7Fk2pAPsw1dXhd00 kFAPAxdPn/mCfArbaoKPeW/4qWjq6/f2Z3+kEEHKkIY2ipbxICvCDQPek+pO0EsWcdPv oFQnpft9fsfHMYwhqGo2rNlnSZrldYCqhcxE3xcxwv6LO/yy5+ZU/otGk9+hA2Cdt12r RxKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=HTAQ4KU4Iqt11BnvPCPe6S12B08TDOK6VXQQF9JzUIo=; b=FL/LbrIF48Mz1ZN0FDxfQlmdZ2SVr4SRnyPY573ws3unH9BRI2sIZ8OxG3LM4MdlYU caSNeW6a4aNAJAPlqfkKii6yUZ8cPZOgt5m442zIoLQ8Hm37KyGzNyAG8Q6rxYlt+Ntt xajkrP1aB61ZuGzNObyLqltl9aicpnOrhIlm5X9IwA4TwGqav8MvcZt97TCAxlg73cSg KDQ4sc7Iv9RlKhuEycPYnvGzgfcFudu70Er3cxYHY+9X/oW7USWiRNzO3B+vRfrPHTxK k9cHzks9QjvnVUeJcz2qS5ylRIpNBMOlexE9vuo5/xyqqB+99r+QgUEQeOZMHlEj6JwQ 5VTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 19si8067957pfi.285.2018.04.06.07.27.05; Fri, 06 Apr 2018 07:27:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756807AbeDFOZj (ORCPT + 99 others); Fri, 6 Apr 2018 10:25:39 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33096 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932300AbeDFNhn (ORCPT ); Fri, 6 Apr 2018 09:37:43 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4FD23CC8; Fri, 6 Apr 2018 13:37:34 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, "Yan, Zheng" , Ilya Dryomov Subject: [PATCH 4.14 12/67] ceph: only dirty ITER_IOVEC pages for direct read Date: Fri, 6 Apr 2018 15:23:42 +0200 Message-Id: <20180406084342.906759671@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084341.225558262@linuxfoundation.org> References: <20180406084341.225558262@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yan, Zheng commit 85784f9395987a422fa04263e7c0fb13da11eb5c upstream. If a page is already locked, attempting to dirty it leads to a deadlock in lock_page(). This is what currently happens to ITER_BVEC pages when a dio-enabled loop device is backed by ceph: $ losetup --direct-io /dev/loop0 /mnt/cephfs/img $ xfs_io -c 'pread 0 4k' /dev/loop0 Follow other file systems and only dirty ITER_IOVEC pages. Cc: stable@kernel.org Signed-off-by: "Yan, Zheng" Reviewed-by: Ilya Dryomov Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- fs/ceph/file.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -635,7 +635,8 @@ static ssize_t ceph_sync_read(struct kio struct ceph_aio_request { struct kiocb *iocb; size_t total_len; - int write; + bool write; + bool should_dirty; int error; struct list_head osd_reqs; unsigned num_reqs; @@ -745,7 +746,7 @@ static void ceph_aio_complete_req(struct } } - ceph_put_page_vector(osd_data->pages, num_pages, !aio_req->write); + ceph_put_page_vector(osd_data->pages, num_pages, aio_req->should_dirty); ceph_osdc_put_request(req); if (rc < 0) @@ -842,6 +843,7 @@ ceph_direct_read_write(struct kiocb *ioc size_t count = iov_iter_count(iter); loff_t pos = iocb->ki_pos; bool write = iov_iter_rw(iter) == WRITE; + bool should_dirty = !write && iter_is_iovec(iter); if (write && ceph_snap(file_inode(file)) != CEPH_NOSNAP) return -EROFS; @@ -909,6 +911,7 @@ ceph_direct_read_write(struct kiocb *ioc if (aio_req) { aio_req->iocb = iocb; aio_req->write = write; + aio_req->should_dirty = should_dirty; INIT_LIST_HEAD(&aio_req->osd_reqs); if (write) { aio_req->mtime = mtime; @@ -966,7 +969,7 @@ ceph_direct_read_write(struct kiocb *ioc len = ret; } - ceph_put_page_vector(pages, num_pages, !write); + ceph_put_page_vector(pages, num_pages, should_dirty); ceph_osdc_put_request(req); if (ret < 0)