From patchwork Mon Nov 17 07:57:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 5315851 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C3790C11AC for ; Mon, 17 Nov 2014 07:58:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0EF02201FB for ; Mon, 17 Nov 2014 07:58:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16FF7201FA for ; Mon, 17 Nov 2014 07:58:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751510AbaKQH6S (ORCPT ); Mon, 17 Nov 2014 02:58:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42203 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751483AbaKQH6Q (ORCPT ); Mon, 17 Nov 2014 02:58:16 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAH7w7jH018233 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Nov 2014 02:58:08 -0500 Received: from localhost.localdomain (vpn1-115-31.nay.redhat.com [10.66.115.31]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAH7vHxN013191; Mon, 17 Nov 2014 02:58:04 -0500 From: "Yan, Zheng" To: ceph-devel@vger.kernel.org Cc: liwang@ubuntukylin.com, "Yan, Zheng" Subject: [PATCH 10/12] ceph: convert inline data for memory mapped read Date: Mon, 17 Nov 2014 15:57:04 +0800 Message-Id: <1416211026-11524-11-git-send-email-zyan@redhat.com> In-Reply-To: <1416211026-11524-1-git-send-email-zyan@redhat.com> References: <1416211026-11524-1-git-send-email-zyan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@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=unavailable 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 We can't use getattr to fetch inline data while holding Fr caps, If there is no Fc cap, ceph_get_caps() does not bring inline data to page cache neither. To simplify this case, just convert inline data to normal data. Signed-off-by: Yan, Zheng --- fs/ceph/addr.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 72336bd..1768919 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1215,7 +1215,7 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) struct page *pinned_page = NULL; loff_t off = vmf->pgoff << PAGE_CACHE_SHIFT; int want, got, ret; - +again: dout("filemap_fault %p %llx.%llx %llu~%zd trying to get caps\n", inode, ceph_vinop(inode), off, (size_t)PAGE_CACHE_SIZE); if (fi->fmode & CEPH_FILE_MODE_LAZY) @@ -1236,7 +1236,10 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) dout("filemap_fault %p %llu~%zd got cap refs on %s\n", inode, off, (size_t)PAGE_CACHE_SIZE, ceph_cap_string(got)); - ret = filemap_fault(vma, vmf); + if ((got & want) || ci->i_inline_version == CEPH_INLINE_NONE) + ret = filemap_fault(vma, vmf); + else + ret = -EAGAIN; /* readpage() can't fetch inline data */ dout("filemap_fault %p %llu~%zd dropping cap refs on %s ret %d\n", inode, off, (size_t)PAGE_CACHE_SIZE, ceph_cap_string(got), ret); @@ -1244,6 +1247,16 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) page_cache_release(pinned_page); ceph_put_cap_refs(ci, got); + if (ret == -EAGAIN) { + ret = ceph_uninline_data(vma->vm_file, NULL); + if (ret < 0) + return VM_FAULT_SIGBUS; + spin_lock(&ci->i_ceph_lock); + ci->i_inline_version = CEPH_INLINE_NONE; + spin_unlock(&ci->i_ceph_lock); + goto again; + } + return ret; }