From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay.sgi.com (relay3.corp.sgi.com [198.149.34.15]) by oss.sgi.com (Postfix) with ESMTP id 6D8AD7F6C for ; Thu, 18 Jun 2015 16:29:39 -0500 (CDT) Received: from cuda.sgi.com (cuda1.sgi.com [192.48.157.11]) by relay3.corp.sgi.com (Postfix) with ESMTP id 07804AC005 for ; Thu, 18 Jun 2015 14:29:35 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id xZwkS8zx8MxR6MXl (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO) for ; Thu, 18 Jun 2015 14:29:35 -0700 (PDT) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 04F152DD2E8 for ; Thu, 18 Jun 2015 21:29:35 +0000 (UTC) Received: from liberator.sandeen.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5ILTXsQ031272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 18 Jun 2015 17:29:34 -0400 Message-ID: <5583383D.4070906@redhat.com> Date: Thu, 18 Jun 2015 16:29:33 -0500 From: Eric Sandeen MIME-Version: 1.0 Subject: [PATCH] xfs_repair: automatically enable -f (file) mode when needed List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com To: xfs-oss If we specify "-f" to xfs_repair, it recognizes that it's working on a file, and if the underlying filesystem sector size differs such that direct IO won't work, it disables direct IO. It's odd, though, that we'd need to specify this, and the failure is non-obvious: # xfs_repair /mnt/test/foo.img Phase 1 - find and verify superblock... xfs_repair: read failed: Invalid argument I see no advantage to requirin the administrator to jump through this hoop; why not just detect that it's a file, and move on? Signed-off-by: Eric Sandeen --- diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 834697a..2d376be 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -573,6 +573,18 @@ main(int argc, char **argv) exit(1); } + /* -f forces this, but let's be nice and autodetect it, as well. */ + if (!isa_file) { + int fd = libxfs_device_to_fd(x.ddev); + struct stat64 statbuf; + + if (fstat64(fd, &statbuf) < 0) + do_warn(_("%s: couldn't stat \"%s\"\n"), + progname, fs_name); + if (S_ISREG(statbuf.st_mode)) + isa_file = 1; + } + /* * if the sector size of the filesystem we are trying to repair is * smaller than that of the underlying filesystem (i.e. we are repairing _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs