From patchwork Thu Feb 20 01:41:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11392909 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6B07138D for ; Thu, 20 Feb 2020 01:42:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5A1A24673 for ; Thu, 20 Feb 2020 01:42:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="rVek4w3C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727370AbgBTBmD (ORCPT ); Wed, 19 Feb 2020 20:42:03 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:47928 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726784AbgBTBmD (ORCPT ); Wed, 19 Feb 2020 20:42:03 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1c5GM039434; Thu, 20 Feb 2020 01:41:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=Mx7XDorpQ81/5IKdsQsCtd/KiumvdWMUZdGMmtXEJ8A=; b=rVek4w3CKwzBn1vpgqXAtEkU8cNWOuR22lzc8SHtRxZYT/7YBALZGRRta/uwJLydS/CM Hx+3QphwHpseP6owpVYLQEcRj+pSnRxgfx/vTHkQRbAP3X4sCqMPjP4JiIIW7AYPuO/m u3N84tEmwvXNQukI9Mot1HSekxBeTqVHTXi194y5cXSOZtsAEFVfVu03Fw7bsAgmPTPD DKPMIJDBdlAyEoNF8omkwqfmNCVPzLcAo7DLwZ8Pa822kwIBJRixOTPOtaJv39hF/uWA Ie0WieMRAMX6HRY7N+kUBvIIirMa5PcjIK7zg62N6RZBSP4gHdi7mT1KmgJzls5gd6G6 +A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2y8ud16s7n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:41:55 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1bf4x050490; Thu, 20 Feb 2020 01:41:55 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2y8ud2g1pd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:41:55 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01K1fnbf002199; Thu, 20 Feb 2020 01:41:49 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 Feb 2020 17:41:48 -0800 Subject: [PATCH 1/8] libxfs: libxfs_buf_delwri_submit should write buffers immediately From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, Allison Collins , Christoph Hellwig Date: Wed, 19 Feb 2020 17:41:48 -0800 Message-ID: <158216290799.601264.17364540721786910264.stgit@magnolia> In-Reply-To: <158216290180.601264.5491208016048898068.stgit@magnolia> References: <158216290180.601264.5491208016048898068.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 adultscore=0 spamscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200010 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 priorityscore=1501 phishscore=0 impostorscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200010 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong The whole point of libxfs_buf_delwri_submit is to submit a bunch of buffers for write and wait for the response. Unfortunately, while it does mark the buffers dirty, it doesn't actually flush them and lets the cache mru flusher do it. This is inconsistent with the kernel API, which actually writes the buffers and returns any IO errors. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins Reviewed-by: Christoph Hellwig --- libxfs/rdwr.c | 3 ++- mkfs/xfs_mkfs.c | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 0d9d7202..2e9f66cc 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -1491,9 +1491,10 @@ xfs_buf_delwri_submit( list_for_each_entry_safe(bp, n, buffer_list, b_list) { list_del_init(&bp->b_list); - error2 = libxfs_writebuf(bp, 0); + error2 = libxfs_writebufr(bp); if (!error) error = error2; + libxfs_putbuf(bp); } return error; diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 5a042917..1f5d2105 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3685,6 +3685,7 @@ main( }; struct list_head buffer_list; + int error; platform_uuid_generate(&cli.uuid); progname = basename(argv[0]); @@ -3885,16 +3886,19 @@ main( if (agno % 16) continue; - if (libxfs_buf_delwri_submit(&buffer_list)) { - fprintf(stderr, _("%s: writing AG headers failed\n"), - progname); + error = -libxfs_buf_delwri_submit(&buffer_list); + if (error) { + fprintf(stderr, + _("%s: writing AG headers failed, err=%d\n"), + progname, error); exit(1); } } - if (libxfs_buf_delwri_submit(&buffer_list)) { - fprintf(stderr, _("%s: writing AG headers failed\n"), - progname); + error = -libxfs_buf_delwri_submit(&buffer_list); + if (error) { + fprintf(stderr, _("%s: writing AG headers failed, err=%d\n"), + progname, error); exit(1); } From patchwork Thu Feb 20 01:41:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11392911 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FB9217E0 for ; Thu, 20 Feb 2020 01:42:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E3A3A24670 for ; Thu, 20 Feb 2020 01:42:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="tV0bIgH+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726784AbgBTBmD (ORCPT ); Wed, 19 Feb 2020 20:42:03 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:60216 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727338AbgBTBmD (ORCPT ); Wed, 19 Feb 2020 20:42:03 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1dTSv113434; Thu, 20 Feb 2020 01:41:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=aEUgbIu5g9mZM0aIM6XSlPvo223tYkKwcXyzpT3Ps90=; b=tV0bIgH+oo3Z9T2swBAYOweNmkJbfN4MegVYWmcQd5E5O25wY+BOkjSl/5tU0CTdq4FP DCh0R5L4xWPiR6OliqxqXL+D88CsZ3kmfeUJ9yTN/vEjK8LDypXFujY4q2sJwI0716Mc MECTlJR0iuiy5/IEtC0h6vYsuc2pzyHdm493CLVUCkVIDnOBqJ8nIxs9YZz33Gkgrpxk dZf6ExOh4vePVtHscVf7o7/IdHgg2+R02QzfElWL246OygK1w57sfPlI5wyRyvF7xpEy v4jLMjy9PTQ+CPlmrbGvdKKtK/O2X8C0ICnYvkNIYIZPCFLw4XAghGJUEsUZWJOsZqrX Mw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2y8udkesv9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:41:59 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1flY2145861; Thu, 20 Feb 2020 01:41:58 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2y8ud4pw74-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:41:58 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01K1ft7C002339; Thu, 20 Feb 2020 01:41:55 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 Feb 2020 17:41:55 -0800 Subject: [PATCH 2/8] libxfs: complain when write IOs fail From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, Allison Collins , Christoph Hellwig Date: Wed, 19 Feb 2020 17:41:54 -0800 Message-ID: <158216291420.601264.11744188975956925500.stgit@magnolia> In-Reply-To: <158216290180.601264.5491208016048898068.stgit@magnolia> References: <158216290180.601264.5491208016048898068.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=969 mlxscore=0 adultscore=0 spamscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200011 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 suspectscore=0 spamscore=0 priorityscore=1501 adultscore=0 mlxscore=0 clxscore=1015 malwarescore=0 mlxlogscore=999 phishscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200010 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Complain whenever a metadata write fails. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins Reviewed-by: Christoph Hellwig --- libxfs/rdwr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 2e9f66cc..8b47d438 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -1149,7 +1149,12 @@ libxfs_writebufr(xfs_buf_t *bp) (long long)LIBXFS_BBTOOFF64(bp->b_bn), (long long)bp->b_bn, bp, bp->b_error); #endif - if (!bp->b_error) { + if (bp->b_error) { + fprintf(stderr, + _("%s: write failed on %s bno 0x%llx/0x%x, err=%d\n"), + __func__, bp->b_ops->name, + (long long)bp->b_bn, bp->b_bcount, -bp->b_error); + } else { bp->b_flags |= LIBXFS_B_UPTODATE; bp->b_flags &= ~(LIBXFS_B_DIRTY | LIBXFS_B_EXIT | LIBXFS_B_UNCHECKED); From patchwork Thu Feb 20 01:42:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11392913 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2B85138D for ; Thu, 20 Feb 2020 01:42:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B42E024671 for ; Thu, 20 Feb 2020 01:42:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="M3ZfTO2a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727402AbgBTBmG (ORCPT ); Wed, 19 Feb 2020 20:42:06 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:60278 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727338AbgBTBmG (ORCPT ); Wed, 19 Feb 2020 20:42:06 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1dIC5112981; Thu, 20 Feb 2020 01:42:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=8xL7qF9tvmSvXDoC4uO3vBJxq0NjddwfYnr2X/6QYc0=; b=M3ZfTO2aRum4FEdUtrXHcNnzkGaEq5bA+2pIx67ypa9otk7FJ67c5Sk8cahfa0aMQexT kURdchO35Jfgy7KANhVpGSCuTWo3T4Ox1PiNEFGy94p41HJbGEtDlm9VcCOiFpqdRutm pjqIAQqJYnBE6ft92wf3uyLxDbz0ZfmHeM382XPCTBw2d6DODBQ6KDgJoz4AVGrwKRD7 wY+zaOEx5wDQgDq0MbiOLAmTccaTCef16QQuRu4Iu3SULd9dpDT7wOSd+KMZGFKZrpc5 HzStJf0rtFH2Yj74tlOcKWnQDLwv9F8Dgoutr8fO9wZkzqLOmSPBBR27kDMXoWx/0WoT Vg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2y8udkesvg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:02 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1cPEK030968; Thu, 20 Feb 2020 01:42:02 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2y8udbmehe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:02 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01K1g1hB001477; Thu, 20 Feb 2020 01:42:01 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 Feb 2020 17:42:01 -0800 Subject: [PATCH 3/8] libxfs: return flush failures From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, Allison Collins , Christoph Hellwig Date: Wed, 19 Feb 2020 17:42:00 -0800 Message-ID: <158216292041.601264.6025267041941901980.stgit@magnolia> In-Reply-To: <158216290180.601264.5491208016048898068.stgit@magnolia> References: <158216290180.601264.5491208016048898068.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200010 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 suspectscore=0 spamscore=0 priorityscore=1501 adultscore=0 mlxscore=0 clxscore=1015 malwarescore=0 mlxlogscore=999 phishscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200010 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Modify platform_flush_device so that we can return error status when device flushes fail. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins Reviewed-by: Christoph Hellwig --- libfrog/linux.c | 25 +++++++++++++++++-------- libfrog/platform.h | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/libfrog/linux.c b/libfrog/linux.c index 41a168b4..60bc1dc4 100644 --- a/libfrog/linux.c +++ b/libfrog/linux.c @@ -140,20 +140,29 @@ platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fata return error; } -void -platform_flush_device(int fd, dev_t device) +/* + * Flush dirty pagecache and disk write cache to stable media. Returns 0 for + * success or -1 (with errno set) for failure. + */ +int +platform_flush_device( + int fd, + dev_t device) { struct stat st; + int ret; + if (major(device) == RAMDISK_MAJOR) - return; + return 0; - if (fstat(fd, &st) < 0) - return; + ret = fstat(fd, &st); + if (ret) + return ret; if (S_ISREG(st.st_mode)) - fsync(fd); - else - ioctl(fd, BLKFLSBUF, 0); + return fsync(fd); + + return ioctl(fd, BLKFLSBUF, 0); } void diff --git a/libfrog/platform.h b/libfrog/platform.h index 76887e5e..0aef318a 100644 --- a/libfrog/platform.h +++ b/libfrog/platform.h @@ -12,7 +12,7 @@ int platform_check_ismounted(char *path, char *block, struct stat *sptr, int platform_check_iswritable(char *path, char *block, struct stat *sptr); int platform_set_blocksize(int fd, char *path, dev_t device, int bsz, int fatal); -void platform_flush_device(int fd, dev_t device); +int platform_flush_device(int fd, dev_t device); char *platform_findrawpath(char *path); char *platform_findblockpath(char *path); int platform_direct_blockdev(void); From patchwork Thu Feb 20 01:42:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11392915 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2BC9C17E0 for ; Thu, 20 Feb 2020 01:42:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0318F24670 for ; Thu, 20 Feb 2020 01:42:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="UmxcMzpj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727291AbgBTBmQ (ORCPT ); Wed, 19 Feb 2020 20:42:16 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:60454 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727280AbgBTBmQ (ORCPT ); Wed, 19 Feb 2020 20:42:16 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1dLir113007; Thu, 20 Feb 2020 01:42:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=2SxI9FoQKh89rHnh61+M5hGx1Qv4ydtTOPumcMwvE98=; b=UmxcMzpjr9xqhJewQqMTiJwNauDtHtxt4pAPdfIAkeUjHVbC5sQ2ngc1LqvcFKaYPqzQ 6XSk+Kc4NTz2fKK1snQNOf7Lr7qKk2+Yb0Kslch2/LHDNi8bZzSseUaE3WJErQ1+v8gS is4OCxMCs7KPtdbeMvygerjX47orPFHcuXwtGbQ6qt8JUEfBUsoTJvrPyNo/u1sxhOHG g0RpQcGjNycIv9gFjCFoOsu7W7el6FGmnsmhXKKDJprxIpWG0BpMocvRU1LI4dlAfXCD vnv17eleXGdL5VqqaBr54I6DIXgGXTrypIvhNMCck/yIC8hpuF/W48GqVfRUdTFX8KF1 mg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2y8udkesw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:14 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1gEro094272; Thu, 20 Feb 2020 01:42:14 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2y8udbmepe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:14 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01K1g8mK001616; Thu, 20 Feb 2020 01:42:08 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 Feb 2020 17:42:08 -0800 Subject: [PATCH 4/8] libxfs: enable tools to check that metadata updates have been committed From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Wed, 19 Feb 2020 17:42:06 -0800 Message-ID: <158216292664.601264.186457838279269618.stgit@magnolia> In-Reply-To: <158216290180.601264.5491208016048898068.stgit@magnolia> References: <158216290180.601264.5491208016048898068.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 suspectscore=2 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200011 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 suspectscore=2 spamscore=0 priorityscore=1501 adultscore=0 mlxscore=0 clxscore=1015 malwarescore=0 mlxlogscore=999 phishscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200010 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Add a new function that will ensure that everything we changed has landed on stable media, and report the results. Subsequent commits will teach the individual programs to report when things go wrong. Signed-off-by: Darrick J. Wong --- include/xfs_mount.h | 3 +++ libxfs/init.c | 43 +++++++++++++++++++++++++++++++++++++++++++ libxfs/libxfs_io.h | 2 ++ libxfs/rdwr.c | 27 +++++++++++++++++++++++++-- 4 files changed, 73 insertions(+), 2 deletions(-) diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 29b3cc1b..c80aaf69 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -187,4 +187,7 @@ extern xfs_mount_t *libxfs_mount (xfs_mount_t *, xfs_sb_t *, extern void libxfs_umount (xfs_mount_t *); extern void libxfs_rtmount_destroy (xfs_mount_t *); +void libxfs_flush_devices(struct xfs_mount *mp, int *datadev, int *logdev, + int *rtdev); + #endif /* __XFS_MOUNT_H__ */ diff --git a/libxfs/init.c b/libxfs/init.c index a0d4b7f4..d1d3f4df 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -569,6 +569,8 @@ libxfs_buftarg_alloc( } btp->bt_mount = mp; btp->dev = dev; + btp->lost_writes = false; + return btp; } @@ -791,6 +793,47 @@ libxfs_rtmount_destroy(xfs_mount_t *mp) mp->m_rsumip = mp->m_rbmip = NULL; } +static inline int +libxfs_flush_buftarg( + struct xfs_buftarg *btp) +{ + if (btp->lost_writes) + return -ENOTRECOVERABLE; + + return libxfs_blkdev_issue_flush(btp); +} + +/* + * Purge the buffer cache to write all dirty buffers to disk and free all + * incore buffers. Buffers that cannot be written will cause the lost_writes + * flag to be set in the buftarg. If there were no lost writes, flush the + * device to make sure the writes made it to stable storage. + * + * For each device, the return code will be set to -ENOTRECOVERABLE if we + * couldn't write something to disk; or the results of the block device flush + * operation. + */ +void +libxfs_flush_devices( + struct xfs_mount *mp, + int *datadev, + int *logdev, + int *rtdev) +{ + *datadev = *logdev = *rtdev = 0; + + libxfs_bcache_purge(); + + if (mp->m_ddev_targp) + *datadev = libxfs_flush_buftarg(mp->m_ddev_targp); + + if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) + *logdev = libxfs_flush_buftarg(mp->m_logdev_targp); + + if (mp->m_rtdev_targp) + *rtdev = libxfs_flush_buftarg(mp->m_rtdev_targp); +} + /* * Release any resource obtained during a mount. */ diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h index 579df52b..fc0fd060 100644 --- a/libxfs/libxfs_io.h +++ b/libxfs/libxfs_io.h @@ -23,10 +23,12 @@ struct xfs_perag; struct xfs_buftarg { struct xfs_mount *bt_mount; dev_t dev; + bool lost_writes; }; extern void libxfs_buftarg_init(struct xfs_mount *mp, dev_t ddev, dev_t logdev, dev_t rtdev); +int libxfs_blkdev_issue_flush(struct xfs_buftarg *btp); #define LIBXFS_BBTOOFF64(bbs) (((xfs_off_t)(bbs)) << BBSHIFT) diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 8b47d438..92e497f9 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -17,6 +17,7 @@ #include "xfs_inode_fork.h" #include "xfs_inode.h" #include "xfs_trans.h" +#include "libfrog/platform.h" #include "libxfs.h" /* for LIBXFS_EXIT_ON_FAILURE */ @@ -1227,9 +1228,11 @@ libxfs_brelse( if (!bp) return; - if (bp->b_flags & LIBXFS_B_DIRTY) + if (bp->b_flags & LIBXFS_B_DIRTY) { fprintf(stderr, "releasing dirty buffer to free list!\n"); + bp->b_target->lost_writes = true; + } pthread_mutex_lock(&xfs_buf_freelist.cm_mutex); list_add(&bp->b_node.cn_mru, &xfs_buf_freelist.cm_list); @@ -1248,9 +1251,11 @@ libxfs_bulkrelse( return 0 ; list_for_each_entry(bp, list, b_node.cn_mru) { - if (bp->b_flags & LIBXFS_B_DIRTY) + if (bp->b_flags & LIBXFS_B_DIRTY) { fprintf(stderr, "releasing dirty buffer (bulk) to free list!\n"); + bp->b_target->lost_writes = true; + } count++; } @@ -1479,6 +1484,24 @@ libxfs_irele( kmem_cache_free(xfs_inode_zone, ip); } +/* + * Flush everything dirty in the kernel and disk write caches to stable media. + * Returns 0 for success or a negative error code. + */ +int +libxfs_blkdev_issue_flush( + struct xfs_buftarg *btp) +{ + int fd, ret; + + if (btp->dev == 0) + return 0; + + fd = libxfs_device_to_fd(btp->dev); + ret = platform_flush_device(fd, btp->dev); + return ret ? -errno : 0; +} + /* * Write out a buffer list synchronously. * From patchwork Thu Feb 20 01:42:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11392917 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 166AD1395 for ; Thu, 20 Feb 2020 01:42:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA6B024671 for ; Thu, 20 Feb 2020 01:42:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Ikk51vP2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727338AbgBTBmS (ORCPT ); Wed, 19 Feb 2020 20:42:18 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:48260 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727280AbgBTBmS (ORCPT ); Wed, 19 Feb 2020 20:42:18 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1e2bH041174; Thu, 20 Feb 2020 01:42:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=WxxOWAVWNmEjck9K0065/0ZNdA2/8vQeBxe8Agj4kbo=; b=Ikk51vP21Nd+4SeIff9k7VP0j8+Ljjmz4bJV1c4lCiHQmjDX977ccb+XetshkiX5/U3I argeZku/8sH5mChta9TlfS2CtEBDHpcidps/YseCR/tIehIl59o/3umGY3la+l6ijIAy aGKqH1tHUJrOzgaMdg8txkzEbTeSiF8XfDUtwGJqIcZ9Mi8QJZa2YHVOaXQcnm+3gPeE pnIdRT9itx+nXqXUYIVOm4HcG8GHl1Zc07PWmveoiSUL4yVQYKnPSTudci+eJQkk0wKx mxpKdhfthLnpYZ5pExXwdpDcmJjprDEoTkW5F/e6QT3iTUyf70aY7s0IiDgo7/9LjVHu bw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2y8ud16s93-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:16 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1foXp188363; Thu, 20 Feb 2020 01:42:15 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2y8ud96utd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:15 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01K1gE6J001644; Thu, 20 Feb 2020 01:42:14 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 Feb 2020 17:42:14 -0800 Subject: [PATCH 5/8] xfs_db: check that metadata updates have been committed From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Wed, 19 Feb 2020 17:42:13 -0800 Message-ID: <158216293385.601264.3202158027072387776.stgit@magnolia> In-Reply-To: <158216290180.601264.5491208016048898068.stgit@magnolia> References: <158216290180.601264.5491208016048898068.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200011 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 priorityscore=1501 phishscore=0 impostorscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200010 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Add a new function that will ensure that everything we scribbled on has landed on stable media, and report the results. Signed-off-by: Darrick J. Wong --- db/init.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/db/init.c b/db/init.c index 0ac37368..e92de232 100644 --- a/db/init.c +++ b/db/init.c @@ -184,6 +184,7 @@ main( char *input; char **v; int start_iocur_sp; + int d, l, r; init(argc, argv); start_iocur_sp = iocur_sp; @@ -216,6 +217,19 @@ main( */ while (iocur_sp > start_iocur_sp) pop_cur(); + + libxfs_flush_devices(mp, &d, &l, &r); + if (d) + fprintf(stderr, _("%s: cannot flush data device (%d).\n"), + progname, d); + if (l) + fprintf(stderr, _("%s: cannot flush log device (%d).\n"), + progname, l); + if (r) + fprintf(stderr, _("%s: cannot flush realtime device (%d).\n"), + progname, r); + + libxfs_umount(mp); if (x.ddev) libxfs_device_close(x.ddev); From patchwork Thu Feb 20 01:42:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11392919 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFF2D138D for ; Thu, 20 Feb 2020 01:42:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF86124670 for ; Thu, 20 Feb 2020 01:42:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="DAYAmRjd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727370AbgBTBmY (ORCPT ); Wed, 19 Feb 2020 20:42:24 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:44002 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727280AbgBTBmY (ORCPT ); Wed, 19 Feb 2020 20:42:24 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1dqCU165655; Thu, 20 Feb 2020 01:42:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=y2YV+x4SWUWv3OYlU7mp1ee358cLAq6dUPUVIY7U0qI=; b=DAYAmRjdhF77njkHcMPmYBZa7ne7odb1jRn6JluuKU7n4JHaPZTd/7+oEPWlOJ0ozcJw yUdGSH4ErP5YlIKtw62bI22A/CNcrmt4itSvHi8nMqq1+Cut+fTyikvYa991MMbuxm7S z5USMc4gtaWQIVdW70XoZNPyzlm3ExYEOfswMsvMeKoC9UGcpnwXKebzeteTv2X0QFRi gQ+vVF8IM9fdfaK7ZTzo644cy1Sv+ccLD1U4PPlJ7p5N/TL10PBt8LxjNurYT/Z8Kz90 bHjCAgZdkUM9acwHKTVk1XwpUd3YnGfj4qAN3dvCE6f9kBfGhEXWUruj7ON3FP8rrXJ0 Dw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2y8udd6tbp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:22 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1g3ee146295; Thu, 20 Feb 2020 01:42:21 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2y8ud4pwmy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:21 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01K1gKTJ027353; Thu, 20 Feb 2020 01:42:21 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 Feb 2020 17:42:20 -0800 Subject: [PATCH 6/8] mkfs: check that metadata updates have been committed From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Wed, 19 Feb 2020 17:42:19 -0800 Message-ID: <158216293986.601264.13332308350623716848.stgit@magnolia> In-Reply-To: <158216290180.601264.5491208016048898068.stgit@magnolia> References: <158216290180.601264.5491208016048898068.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 spamscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200011 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200010 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Add a new function that will ensure that everything we formatted has landed on stable media, and report the results. Signed-off-by: Darrick J. Wong --- mkfs/xfs_mkfs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 1f5d2105..6b182264 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3644,6 +3644,7 @@ main( char *protofile = NULL; char *protostring = NULL; int worst_freelist = 0; + int d, l, r; struct libxfs_xinit xi = { .isdirect = LIBXFS_DIRECT, @@ -3940,6 +3941,20 @@ main( (XFS_BUF_TO_SBP(buf))->sb_inprogress = 0; libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); + /* Make sure our new fs made it to stable storage. */ + libxfs_flush_devices(mp, &d, &l, &r); + if (d) + fprintf(stderr, _("%s: cannot flush data device (%d).\n"), + progname, d); + if (l) + fprintf(stderr, _("%s: cannot flush log device (%d).\n"), + progname, l); + if (r) + fprintf(stderr, _("%s: cannot flush realtime device (%d).\n"), + progname, r); + if (d || l || r) + return 1; + libxfs_umount(mp); if (xi.rtdev) libxfs_device_close(xi.rtdev); From patchwork Thu Feb 20 01:42:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11392921 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 148FF1395 for ; Thu, 20 Feb 2020 01:42:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EACC024671 for ; Thu, 20 Feb 2020 01:42:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="MNaiU0xu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726784AbgBTBmb (ORCPT ); Wed, 19 Feb 2020 20:42:31 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:48420 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727476AbgBTBmb (ORCPT ); Wed, 19 Feb 2020 20:42:31 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1cUtY039822; Thu, 20 Feb 2020 01:42:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=baj94MHEM+IJpZ8LpMTDIXZKBjr47MuJ1Eg2bbwhU/w=; b=MNaiU0xuV2IfVCUwjOJX7TT0TmDXfFbzX0KVCqv5H978QxfzCHRwCNMmdijen7wJh2EX C0cYJ4ILsUQ6sxvDRPDGo6vPYv1xvrv8frKYlPHBPhSCY3YwZqq3sUqxoN3Xmh7j4NV5 +L3fvOMB0EHgvmGbqIWtWjxYnw/yT0zFSy4vULz5ZW5znJ9HlqAR9EJn3VHq0h/6KTHR w9hkljTGw+104idoISNASiOs1Af/MwMyYR7PzHTfeRbn2MFRbd8IPLhwR6ohjilGU5YS 7FB5HhZuE4CQtJp0J2qp0yaHQCT/X0bkXnDgf0VOq81buqvvuXmB/Ny1bF9vECQVYMu/ gA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2y8ud16s9e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:28 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1gJE7189098; Thu, 20 Feb 2020 01:42:28 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2y8ud96wn7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:28 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01K1gRZv005854; Thu, 20 Feb 2020 01:42:27 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 Feb 2020 17:42:26 -0800 Subject: [PATCH 7/8] xfs_repair: check that metadata updates have been committed From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Wed, 19 Feb 2020 17:42:25 -0800 Message-ID: <158216294593.601264.16626864880754547783.stgit@magnolia> In-Reply-To: <158216290180.601264.5491208016048898068.stgit@magnolia> References: <158216290180.601264.5491208016048898068.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=2 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200011 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 malwarescore=0 suspectscore=2 bulkscore=0 spamscore=0 priorityscore=1501 phishscore=0 impostorscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200010 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Add a new function that will ensure that everything we changed has landed on stable media, and report the results. Signed-off-by: Darrick J. Wong --- repair/xfs_repair.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index eb1ce546..c0a77cad 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -690,6 +690,36 @@ check_fs_vs_host_sectsize( } } +/* Flush the devices and complain if anything bad happened. */ +static bool +check_write_failed( + struct xfs_mount *mp) +{ + int d, l, r; + + libxfs_flush_devices(mp, &d, &l, &r); + + if (d == -ENOTRECOVERABLE) + do_warn(_("Lost writes to data device, please re-run.\n")); + else if (d) + do_warn(_("Error %d flushing data device, please re-run.\n"), + -d); + + if (l == -ENOTRECOVERABLE) + do_warn(_("Lost writes to log device, please re-run.\n")); + else if (l) + do_warn(_("Error %d flushing log device, please re-run.\n"), + -l); + + if (r == -ENOTRECOVERABLE) + do_warn(_("Lost writes to realtime device, please re-run.\n")); + else if (r) + do_warn(_("Error %d flushing realtime device, please re-run.\n"), + -r); + + return d || l || r; +} + int main(int argc, char **argv) { @@ -703,6 +733,7 @@ main(int argc, char **argv) struct xfs_sb psb; int rval; struct xfs_ino_geometry *igeo; + bool writes_failed; progname = basename(argv[0]); setlocale(LC_ALL, ""); @@ -1106,6 +1137,8 @@ _("Note - stripe unit (%d) and width (%d) were copied from a backup superblock.\ format_log_max_lsn(mp); libxfs_umount(mp); + writes_failed = check_write_failed(mp); + if (x.rtdev) libxfs_device_close(x.rtdev); if (x.logdev && x.logdev != x.ddev) @@ -1125,6 +1158,8 @@ _("Repair of readonly mount complete. Immediate reboot encouraged.\n")); free(msgbuf); + if (writes_failed) + return 1; if (fs_is_dirty && report_corrected) return (4); return (0); From patchwork Thu Feb 20 01:42:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11392923 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27F631395 for ; Thu, 20 Feb 2020 01:42:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0829524670 for ; Thu, 20 Feb 2020 01:42:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Kk+0yYOe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727476AbgBTBmg (ORCPT ); Wed, 19 Feb 2020 20:42:36 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:44138 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727135AbgBTBmg (ORCPT ); Wed, 19 Feb 2020 20:42:36 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1d4RN164632; Thu, 20 Feb 2020 01:42:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=o/OsrdBU1dw06qQ3gRT7D+qVqYYUS4o7LTutOljcqfo=; b=Kk+0yYOeNwlf9S3hDM/+JmV5I1sB2dbh0PDvSup0owF+C48ltmpG2YfKO+ey9REuDyKB 6I/j13ZyFeMmZPPHJiH6eMhD/1S73fJsGyGliw78c1LCMsAjqZsRYEy0uYcK3+N53/QG WmSCRLrjDv43XGxbJ6nh1of/7oUO1/mtFmsSwX+RM4s394TPp3HNjIbiIZLpLshSDv/x chFINQhp4tHCYinwcs+9fNCX9hSK39RcIp96Tnthl/xu5eJPWrsN8z19AEXRoBf0TTTv k3c9yj44i3gMvAGBH6QNjEElTWtSoRNCU7PEj8bECTcw8NxEydId0/JxQYfO+KHQ4/zT TQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2y8udd6tc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:34 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K1bc1Q050387; Thu, 20 Feb 2020 01:42:34 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2y8ud2g2dy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 01:42:33 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01K1gX3q002606; Thu, 20 Feb 2020 01:42:33 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 Feb 2020 17:42:32 -0800 Subject: [PATCH 8/8] libfrog: always fsync when flushing a device From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Wed, 19 Feb 2020 17:42:31 -0800 Message-ID: <158216295197.601264.12572804096602430873.stgit@magnolia> In-Reply-To: <158216290180.601264.5491208016048898068.stgit@magnolia> References: <158216290180.601264.5491208016048898068.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxlogscore=947 suspectscore=0 adultscore=0 spamscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200010 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 impostorscore=0 mlxlogscore=998 malwarescore=0 mlxscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200010 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Always call fsync() when we're flushing a device, even if it is a block device. It's probably redundant to call fsync /and/ BLKFLSBUF, but the latter has odd behavior so we want to make sure the standard flush methods have a chance to run first. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- libfrog/linux.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libfrog/linux.c b/libfrog/linux.c index 60bc1dc4..40a839d1 100644 --- a/libfrog/linux.c +++ b/libfrog/linux.c @@ -155,14 +155,18 @@ platform_flush_device( if (major(device) == RAMDISK_MAJOR) return 0; + ret = fsync(fd); + if (ret) + return ret; + ret = fstat(fd, &st); if (ret) return ret; - if (S_ISREG(st.st_mode)) - return fsync(fd); + if (S_ISBLK(st.st_mode)) + return ioctl(fd, BLKFLSBUF, 0); - return ioctl(fd, BLKFLSBUF, 0); + return 0; } void