From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B047C2D0C4 for ; Tue, 10 Dec 2019 10:10:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 525EB2073D for ; Tue, 10 Dec 2019 10:10:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727128AbfLJKKT (ORCPT ); Tue, 10 Dec 2019 05:10:19 -0500 Received: from mx2.suse.de ([195.135.220.15]:44322 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727016AbfLJKKT (ORCPT ); Tue, 10 Dec 2019 05:10:19 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 14922B12D; Tue, 10 Dec 2019 10:10:18 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 5B51D1E0B23; Tue, 10 Dec 2019 11:10:17 +0100 (CET) Date: Tue, 10 Dec 2019 11:10:17 +0100 From: Jan Kara To: Kirill Tkhai Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, jack@suse.com, adilger.kernel@dilger.ca Subject: Re: [Q] e4defrag and append-only files Message-ID: <20191210101017.GD1551@quack2.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hi! On Mon 09-12-19 13:54:24, Kirill Tkhai wrote: > on one of production nodes I observe the situation, when many fragmented files > never become defragmented, becase of they have "a" extended attribute. > The reason is append-only file can't be open for write without O_APPEND attribute: > > $lsattr a.txt > -----a--------e----- a.txt > > $strace e4defrag a.txt > openat(AT_FDCWD, "a.txt", O_RDWR) = -1 EPERM (Operation not permitted) > > Simple O_APPEND passed to open() solves the situation. > > The question is: can't we just do this? > > Let's observe the file restrictions we may have. > > "Append-only" extended attribute restriction is weaker, than RO file permissions (0444). > But RO files are being processed by e4defrag, since e4defrag runs by root, and it easily > ignores RO file permissions, while "append-only" files are always ignored by the util. > Is there a fundamental reason we must skip them? I don't think there's a technical reason why we cannot defragment inodes with 'append-only' or even 'immutable' attribute. Just e4defrag would have to remove these flags so that open can succeed (because neither append-only nor immutable flags are overridden by CAP_DAC_OVERRIDE capability - unlike standard unix permissions or xattrs) and then restore the flags after the fact. Whether we really want to do this is another question. I don't think e4defrag should touch immutable files, for append-only files I don't have a strong opinion... Honza -- Jan Kara SUSE Labs, CR