From patchwork Wed Jul 18 11:04:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10532157 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 C85766020A for ; Wed, 18 Jul 2018 11:05:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB40F2842B for ; Wed, 18 Jul 2018 11:05:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF9552909D; Wed, 18 Jul 2018 11:05:25 +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,FREEMAIL_FROM, 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 58C802842B for ; Wed, 18 Jul 2018 11:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728936AbeGRLmq (ORCPT ); Wed, 18 Jul 2018 07:42:46 -0400 Received: from mout.gmx.net ([212.227.15.19]:34425 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727640AbeGRLmq (ORCPT ); Wed, 18 Jul 2018 07:42:46 -0400 Received: from localhost.localdomain ([220.112.58.66]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MAhWl-1flXoj2A8Z-00Btjb; Wed, 18 Jul 2018 13:05:19 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH 1/5] ceph: add new field max_file_size in ceph_fs_client Date: Wed, 18 Jul 2018 19:04:23 +0800 Message-Id: <20180718110427.7775-2-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180718110427.7775-1-cgxu519@gmx.com> References: <20180718110427.7775-1-cgxu519@gmx.com> X-Provags-ID: V03:K1:hhI4eOvazQVl9ztohJZ2qQrePeuYZZ7NdxT1HDDnd6i7qR85128 uB2NJLCF/YPECVSvJRqaMSEb8+0TT5i+k2IjG4bE2fUHbNBxFhsJrkmHsUxSyOG+oM7mBVq cL2nLRPw100rzdwwQCjPDyQD/2iN2d9MQPNELBgzkOKFV6DL/s3FEwTUGYosJN9PId2gapu FUxZdYTodZGI0Ny+Xw+Ew== X-UI-Out-Filterresults: notjunk:1; V01:K0:VlOTljmu5hg=:Ime+RL6OJIe2V/uCoNaFtd Aniw/nTEHLjsZQlv6iq7v4XzoZXoMdI5kvGMCcYv0vy6QHQ4EaaD4+SRJcE7vd3qJHiqFHiHK 3qAjN+RqriwRhF2IYAVMYBLlM1g8orUl+NZGBUS1F3l0Jccjteikv/6tpFjvZ5PggfcTQ1Lvf CKQrSm+XV5rUEs/MeDjN1ZyDEQbnjqsLbXQr59Oy5xitMRdEC4g9PahO1+grW7X/TQgZdvFLs aVIvLmA+HPeblELXyO61HzfVGpDm4W5zjqvsNR2MKfYTb/8HCD6jpfW26ylbrNGFoAJ9DG8BH aKzmpVgtjaTvy1IVOBTb8ECYXdZtA3vC7xqeh2gRwdAbkAauOjhOXMFy62U6fYQ4UcvmM/wVT kYUIU5qyUbvYoc1HeHoIr9WvJhkKmKNTpFGdxvxuO+RAsAjNbZF+rTF8P70nOQsOmHQafdfIv b4dBFsNyq12XfeUV9saSYFIqSHNAh+0lfSfnoSXeAI6czqb3TkDOovezFGjo+OxlIVaJAYvhr hDGXCT16n6OPN7uD/5HNCYtzlp3X4xdsUF81QMQQrlMMvovtlAciM0I3oXGcExt9rww3P5xQN iAa1JRjMnDL1zoO14/Jg0MQOAcXo5frZUFxwNTuMzhRXNMuEVcc6sOp/G9iJOm/cF0QQ34fN9 Pl8MGyR3mQpeXsUMNrA4GZ2/GMvel5+mE3SCWHJpQ6Zqwd/LUOqcFmG0VIE/zpqPTQqowLyb3 lw82jpk3hZ346GZgTuDlQA8ABY8BBOsr0o38jG5by2K+CgTmO41tyTimnHU= Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to not bother to VFS and other specific filesystems, we decided to do offset validation inside ceph kernel client, so just simply set sb->s_maxbytes to MAX_LFS_FILESIZE so that it can successfully pass VFS check. We add new field max_file_size in ceph_fs_client to store real file size limit and doing proper check based on it. Signed-off-by: Chengguang Xu --- fs/ceph/mds_client.c | 3 ++- fs/ceph/super.c | 3 ++- fs/ceph/super.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index df0a3bb0f6a5..13e9e4972e0d 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -4057,7 +4057,8 @@ void ceph_mdsc_handle_mdsmap(struct ceph_mds_client *mdsc, struct ceph_msg *msg) } else { mdsc->mdsmap = newmap; /* first mds map */ } - mdsc->fsc->sb->s_maxbytes = mdsc->mdsmap->m_max_file_size; + mdsc->fsc->max_file_size = min((loff_t)mdsc->mdsmap->m_max_file_size, + MAX_LFS_FILESIZE); __wake_requests(mdsc, &mdsc->waiting_for_map); ceph_monc_got_map(&mdsc->fsc->client->monc, CEPH_SUB_MDSMAP, diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 3d8a26b2944f..43ca3b763875 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -940,11 +940,12 @@ static int ceph_set_super(struct super_block *s, void *data) dout("set_super %p data %p\n", s, data); s->s_flags = fsc->mount_options->sb_flags; - s->s_maxbytes = 1ULL << 40; /* temp value until we get mdsmap */ + s->s_maxbytes = MAX_LFS_FILESIZE; s->s_xattr = ceph_xattr_handlers; s->s_fs_info = fsc; fsc->sb = s; + fsc->max_file_size = 1ULL << 40; /* temp value until we get mdsmap */ s->s_op = &ceph_super_ops; s->s_d_op = &ceph_dentry_ops; diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 5df5262b24b0..de9d7466538a 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -98,6 +98,7 @@ struct ceph_fs_client { unsigned long mount_state; int min_caps; /* min caps i added */ + loff_t max_file_size; struct ceph_mds_client *mdsc;