Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2792767imd; Sun, 28 Oct 2018 18:36:21 -0700 (PDT) X-Google-Smtp-Source: AJdET5eV8EsWbB/pQ6r0smgniQLEJNwjgM0PQ+l5UPwsZipA/3jNQ7cVY3E64QCGXyQnEY3xas9G X-Received: by 2002:a65:5b07:: with SMTP id y7-v6mr11919650pgq.125.1540776980956; Sun, 28 Oct 2018 18:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540776980; cv=none; d=google.com; s=arc-20160816; b=R01KVgq5TdPR9p2kYnXvinX3xkF+4rcqykRaGUUJQ3qwf4c7dsNoL0ffV4jJXiC3yR yl085y6WbhBucfrZWuj3wjpFr8idZ+Sy/lzZG6ULd9c4rxlBQCIrGUvvP0cPhfCBQDUX O56pQBwgSIbIHhoHDsLldrhA7hZ7pS4QJ7p91DOa3UC+CPr+TI/7Vghu9dZcJKbceCMI f5UCokMfo6Bs9wpe7s0v1GZrA5Tdz3NDwDdsp7oV6wYaF0LaZx1WwFClv2CHRpZMpU3Z REaX+RjoYUXT9Oo/g/ocXjSeKOfAEIx6sHiaiUUhIWhdf6hbWNiVC+G42yKu1DalO251 ncaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Y4yxBQTDuhhP1TU3f9Q2XSDgFac9HnATxlD3K0eRx5w=; b=BRjUUwQuFQ+RPhnZhwCe9yUHKBHpN6oQc+kAx/+B01q5gy27itilNmyMDXE9ozi9Ee GHeMaiPbxZ1m+YmLrzRyVy/6D0nW5E4sMIDBrVR9vhoEyDhFr0Cu3MSwi4v7YCiy+ltx rntmTElAQQCOZ1agqQy1BrflHXtJ3kQxqk0SE5l5h7xM1Wb9IDvHQYOiP22Kljg0rxEI GD+sTwRcCu8eWPBiLNZfbQvROC6YGT/TMWhujJXTwHMEFOeMViHiptQPtz90o2QPP6TO wv5UlFsFowCEQzv7CR0TiKradtGQ4Oxb8wE6jKQE/j97lMX1nVe1JpDVPgmgLGRKgQux hdeg== 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 u17-v6si6395479pgj.201.2018.10.28.18.36.05; Sun, 28 Oct 2018 18:36:20 -0700 (PDT) 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 S1726537AbeJ2KSn (ORCPT + 99 others); Mon, 29 Oct 2018 06:18:43 -0400 Received: from ipmail03.adl2.internode.on.net ([150.101.137.141]:26562 "EHLO ipmail03.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbeJ2KSn (ORCPT ); Mon, 29 Oct 2018 06:18:43 -0400 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail03.adl2.internode.on.net with ESMTP; 29 Oct 2018 11:51:00 +1030 Received: from dave by dastard with local (Exim 4.80) (envelope-from ) id 1gGwEl-0003YU-1M; Mon, 29 Oct 2018 12:20:59 +1100 Date: Mon, 29 Oct 2018 12:20:59 +1100 From: Dave Chinner To: Anatoly Trosinenko Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: XFS: Hang and dmesg flood on mounting invalid FS image Message-ID: <20181029012058.GK19305@dastard> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 28, 2018 at 08:50:46PM +0300, Anatoly Trosinenko wrote: > Hello, > > When mounting a broken XFS image, the kernel hangs and floods dmesg > with stack traces. How did the corruption occur? $ sudo xfs_logprint -d /dev/vdc xfs_logprint: data device: 0xfd20 log device: 0xfd20 daddr: 131112 length: 6840 0 HEADER Cycle 1 tail 1:000000 len 512 ops 1 [00000 - 00000] Cycle 0xffffffff New Cycle 0x00000001 2 HEADER Cycle 1 tail 1:000002 len 512 ops 5 4 HEADER Cycle 1 tail -2147483647:000002 len 512 ops 1 ^^^^^^^^^^^^ 6 HEADER Cycle 0 tail 1:000000 len 0 ops 0 [00000 - 00006] Cycle 0x00000001 New Cycle 0x00000000 7 HEADER Cycle 0 tail 1:000000 len 0 ops 0 Ok, so from this the head of the log is block 4, and it has a corrupt tail pointer it points to: $ sudo xfs_logprint -D -s 4 /dev/vdc |head -10 xfs_logprint: data device: 0xfd20 log device: 0xfd20 daddr: 131112 length: 6840 BLKNO: 4 0 bebaedfe 1000000 2000000 20000 1000000 3610000 1000080 2000000 ^^^^^^^ ^ ^ wrong wrong wrong 8 2f27bae6 2000000 1000000 dabdbab0 0 0 0 0 10 0 0 0 0 0 0 0 0 18 0 0 0 0 0 0 0 0 20 0 0 0 0 0 0 0 0 They decode as: cycle: 1 version: 2 lsn: 1,24835 tail_lsn: 2147483649,2 So the tail LSN points to an invalid log cycle and the previous block. IOWs, the block number in the tail indicates the whole log is valid and needs to be scanned. but the cycle is not valid. And that's the problem. Neither the head or tail blocks are validated before they are used. CRC checking of the head and tail blocks comes later.... Cheers, Dave. -- Dave Chinner david@fromorbit.com