Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3698505ybl; Mon, 27 Jan 2020 08:45:17 -0800 (PST) X-Google-Smtp-Source: APXvYqwNArC7g9WhwHgxJaoQqDKUn/wQHSSc+vyv9/t9ikCQthUKe2DjpGWKzPHAf2GvI3ck2cjf X-Received: by 2002:a05:6830:140b:: with SMTP id v11mr6785574otp.340.1580143516991; Mon, 27 Jan 2020 08:45:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580143516; cv=none; d=google.com; s=arc-20160816; b=CYWQK7+v1eN1udqz5PEvbCJYimdNQdUUYNrpvh2Qb2ZhRqcaw7N9e6IIrNo0DDdFj8 o4h6QQOZZ2Gt4ATSWTdDRkqF/jnpxMbnW5K4PAp8OvaCZ9SpD0qh4D81lpmJAk+CCLn8 WFCvmgFDxO+R6KBqvnrN1d3CuGx6lhBjgHuRs7cPbehnbaX8FcmmTfWXBW6W69BJz1L2 6aGq9bYOnqo67Le5BeBF/JnsL9Sio8aaZ+1UeX7bY6xbOvmOLZ9MjEPkktkq5bql93Rm 2/TzfkmuhIBj3KHBYQbpNu1ywVwWStvqTCxzD4SlIOGexGF9uesaxWu0bMQ6iCpmxBnu Raqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vA73me5PZFogkfL0pdjTc9/QWnu6UgYcYLLjfvAU2lo=; b=nBPjYUnvqeokPVN7T1YehyixTFmbEkGWZ9H7EIyr0u567BxQ5Kwfrl17X9On0fupml wVv2BSpojNjJ3DvvMPW7T+WKJrP2hYlm9BJubz/pmW0RJZTSa9EeRMm7jtYArsY5t5/a Ytpg+dE9aDFlFUFgaARa3pk0boAvePgUFZ6OswyarOdi7PDF0xHQfUmcG4oUYh90xzrh ywFfqHsqkzaVp1b1Ca8onILClaqMbhidQ/9ij5AOhznr3uusY9R3MuQ0aC431dKqEWV5 uU3Cv90qDH4AMqKjZLQaoWc7zig77mSz0o9HIwqKLEqmeuLYnAJprfwCHL2Mvj6nStHF 4HIg== 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 j143si3428054oib.16.2020.01.27.08.45.04; Mon, 27 Jan 2020 08:45:16 -0800 (PST) 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 S1726852AbgA0Qnb (ORCPT + 99 others); Mon, 27 Jan 2020 11:43:31 -0500 Received: from mx2.suse.de ([195.135.220.15]:40704 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgA0QnW (ORCPT ); Mon, 27 Jan 2020 11:43:22 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 56CA2B15B; Mon, 27 Jan 2020 16:43:20 +0000 (UTC) From: Luis Henriques To: Jeff Layton , Sage Weil , Ilya Dryomov , "Yan, Zheng" , Gregory Farnum Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Henriques Subject: [RFC PATCH 3/3] ceph: add module param to throttle 'copy-from2' operations Date: Mon, 27 Jan 2020 16:43:21 +0000 Message-Id: <20200127164321.17468-4-lhenriques@suse.com> In-Reply-To: <20200127164321.17468-1-lhenriques@suse.com> References: <20200127164321.17468-1-lhenriques@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds a ceph kernel module parameter that allows to throttle the amount of parallel requests that can be sent to the OSDs before waiting for the completion. This allows to prevent DoS'ing the ODSs with too many requests at once when copying a big file. Signed-off-by: Luis Henriques --- fs/ceph/file.c | 10 ++++++++++ fs/ceph/super.c | 4 ++++ fs/ceph/super.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 5d8f0ba11719..bf18712f3bd3 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1973,6 +1973,7 @@ static ssize_t __ceph_copy_file_range(struct file *src_file, loff_t src_off, int src_got = 0, dst_got = 0, err, dirty; bool do_final_copy = false; LIST_HEAD(osd_reqs); + unsigned int ncopies = cfr_throttle; if (src_inode->i_sb != dst_inode->i_sb) { struct ceph_fs_client *dst_fsc = ceph_inode_to_client(dst_inode); @@ -2151,6 +2152,15 @@ static ssize_t __ceph_copy_file_range(struct file *src_file, loff_t src_off, src_off += object_size; dst_off += object_size; ret += object_size; + if (cfr_throttle && (--ncopies == 0)) { + err = wait_copy_from_reqs(&osd_reqs); + if (err) { + if (!ret) + ret = err; + goto out_caps; + } + ncopies = cfr_throttle; + } } err = wait_copy_from_reqs(&osd_reqs); diff --git a/fs/ceph/super.c b/fs/ceph/super.c index b62c487a53af..02e8b6f93d50 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -1238,6 +1238,10 @@ static void __exit exit_ceph(void) destroy_caches(); } +unsigned int cfr_throttle = 0; +module_param(cfr_throttle, uint, 0644); +MODULE_PARM_DESC(cfr_throttle, "copy_file_range throttle value."); + module_init(init_ceph); module_exit(exit_ceph); diff --git a/fs/ceph/super.h b/fs/ceph/super.h index b2f86bed5c2c..fb98b4b1ec72 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -72,6 +72,8 @@ #define CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT 5 /* cap release delay */ #define CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT 60 /* cap release delay */ +extern unsigned int cfr_throttle; + struct ceph_mount_options { unsigned int flags;