From patchwork Thu Oct 26 14:41:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10028457 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 68F1B6032C for ; Thu, 26 Oct 2017 14:36:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A1DC28E39 for ; Thu, 26 Oct 2017 14:36:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DA3628E3C; Thu, 26 Oct 2017 14:36:56 +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=-6.9 required=2.0 tests=BAYES_00,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 D376E28E39 for ; Thu, 26 Oct 2017 14:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932340AbdJZOgz (ORCPT ); Thu, 26 Oct 2017 10:36:55 -0400 Received: from mga14.intel.com ([192.55.52.115]:6457 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932336AbdJZOgy (ORCPT ); Thu, 26 Oct 2017 10:36:54 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2017 07:36:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,434,1503385200"; d="scan'208";a="167952970" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.44]) by fmsmga006.fm.intel.com with ESMTP; 26 Oct 2017 07:36:54 -0700 From: Keith Busch To: linux-xfs@vger.kernel.org Cc: Keith Busch Subject: [PATCH] xfsprogs: Issue smaller discards at mkfs Date: Thu, 26 Oct 2017 08:41:31 -0600 Message-Id: <20171026144131.26885-1-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Running mkfs.xfs was discarding the entire capacity in a single range. The block layer would split these into potentially many smaller requests and dispatch all of them to the device at roughly the same time. SSD capacities are getting so large that full capacity discards will take some time to complete. When discards are deeply queued, the block layer may trigger timeout handling and IO failure, though the device is operating normally. This patch uses smaller discard ranges in a loop for mkfs to avoid risking such timeouts. The max discard range is arbitrarilly set to 128GB in this patch. Signed-off-by: Keith Busch --- include/linux.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/linux.h b/include/linux.h index 6ce344c5..702aee0c 100644 --- a/include/linux.h +++ b/include/linux.h @@ -132,10 +132,17 @@ static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src) static __inline__ int platform_discard_blocks(int fd, uint64_t start, uint64_t len) { - uint64_t range[2] = { start, len }; + uint64_t end = start + len; + uint64_t size = 128ULL * 1024ULL * 1024ULL * 1024ULL; - if (ioctl(fd, BLKDISCARD, &range) < 0) - return errno; + for (; start < end; start += size) { + uint64_t range[2] = { start, MIN(len, size) }; + + len -= range[1]; + if (ioctl(fd, BLKDISCARD, &range) < 0) + return errno; + + } return 0; }