From patchwork Wed Jun 15 17:42:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9179039 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 EE65660776 for ; Wed, 15 Jun 2016 17:42:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E042827D45 for ; Wed, 15 Jun 2016 17:42:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4CFA27F17; Wed, 15 Jun 2016 17:42:20 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 4BA6827D45 for ; Wed, 15 Jun 2016 17:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932430AbcFORmS (ORCPT ); Wed, 15 Jun 2016 13:42:18 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:35583 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932121AbcFORmR (ORCPT ); Wed, 15 Jun 2016 13:42:17 -0400 Received: by mail-pf0-f170.google.com with SMTP id c2so10882384pfa.2 for ; Wed, 15 Jun 2016 10:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=m5erCqzIFLlA7/PrARwQnprXU8tqTh4ezjKYNsRqY6Y=; b=TVgV9WP2QEsnzgHYME6h9bKao2ciUrfPFUGnb4d+SUvCag4xDM/EyedAegncxcU8/6 TgYa8Nc74EXFPVeIgIUPYzH3ntCoDk/a+yO/1DZ9hYfX1d0CmJ4DI59fsWit8OAfTCRU aIsyv8ffnnZ+rchNLATGsfVhGA/Ol+vCf/2x2eJEGrkWJyAYn/ZaS66zcLcNH2DebbgA 9b4IN05mgbwAbPP5tFiGW+rX/JNiMS+Jcx6CMr7Y51/qQsHaYaN6BloQyNJ+eOTwBVRy chbRSEZIDvJkilyxPkazkbVZLpfO07delUscGe+5x+qwlPjeKd2oshopSNJNBDR15S5r qlDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=m5erCqzIFLlA7/PrARwQnprXU8tqTh4ezjKYNsRqY6Y=; b=AN8WdKzcl1k/FYg5PEAmlpsxVbcv3uyaEUXXRjQcpJ6kZlKUEM0vUL0jgMFOciBx1Y BxT/7ocZOqZ1r0o4djQbAOpygsh/SkI91I3p+vc5Kms5oCXs+P7EjERW5vvGq4zNBhcE KUfFrQGxfW4CTiIMWkHc0YZesuseLro0yrdJHbeyeVcHJutCoJEW9wcCyPaYp5DP9tjv fk5b8ivvpd6j/69oiU9dvYUHz0toQw/1nZEREvXWIT/k6Q7sc3Q/xp3Sx7fcqrP8wNih ZYsdR0z6CLuZ4hkut06fK396UOl1wiAC+HRnwHgGZtBgUOyHt3nuu4phG/ebm1oateqM 9ksg== X-Gm-Message-State: ALyK8tLJEinvXOtAH5WI5M/MSQe11bYHq3riKyD7H5ClnLD3CMA/nBD6q4YowYTBW4cFZNZU X-Received: by 10.98.51.197 with SMTP id z188mr5037345pfz.100.1466012536425; Wed, 15 Jun 2016 10:42:16 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::c:b276]) by smtp.gmail.com with ESMTPSA id q88sm54480067pfj.4.2016.06.15.10.42.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jun 2016 10:42:15 -0700 (PDT) From: Omar Sandoval To: Al Viro , Theodore Ts'o Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, kernel-team@fb.com Subject: [RFC PATCH] coredump: avoid ext4 auto_da_alloc for core file Date: Wed, 15 Jun 2016 10:42:05 -0700 Message-Id: <5cdda475417b2719dced162cce89a283153cb818.1466012020.git.osandov@fb.com> X-Mailer: git-send-email 2.8.3 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval Someone at Facebook reported that their coredumps were much faster when using a pipe helper than when dumping directly to a file, which doesn't make much sense. It turns out that this difference is because in do_coredump(), we truncate the core file and thus trigger the ext4 auto_da_alloc heuristic. We can't use O_TRUNC because we might bail out of do_coredump() in certain conditions, so instead, avoid truncating when the file is already empty. In cases where we're actually overwriting a core file, this won't help, but the common case will be much better. Signed-off-by: Omar Sandoval --- Hi, Al and Ted, This is probably the wrong solution to the problem I described in the commit message. Do you guys have any better ideas? Something like 0eab928221ba ("ext4: Don't treat a truncation of a zero-length file as replace-via-truncate") would also work, but that apparently wasn't right, as it was reverted in 5534fb5bb35a ("ext4: Fix the alloc on close after a truncate hueristic"). Thanks. fs/coredump.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/coredump.c b/fs/coredump.c index 281b768000e6..9da7357773f0 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -741,8 +741,10 @@ void do_coredump(const siginfo_t *siginfo) goto close_fail; if (!(cprm.file->f_mode & FMODE_CAN_WRITE)) goto close_fail; - if (do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file)) - goto close_fail; + if (i_size_read(file_inode(cprm.file)) != 0) { + if (do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file)) + goto close_fail; + } } /* get us an unshared descriptor table; almost always a no-op */