Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752627AbdF3Tgz (ORCPT ); Fri, 30 Jun 2017 15:36:55 -0400 Received: from mail-yb0-f178.google.com ([209.85.213.178]:35924 "EHLO mail-yb0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752573AbdF3Tgw (ORCPT ); Fri, 30 Jun 2017 15:36:52 -0400 MIME-Version: 1.0 In-Reply-To: <18BC3861-631F-4C45-9043-14E92B3D7922@dilger.ca> References: <20170629005029.13302-1-tahsin@google.com> <20170629030618.5101-1-tahsin@google.com> <18BC3861-631F-4C45-9043-14E92B3D7922@dilger.ca> From: Tahsin Erdogan Date: Fri, 30 Jun 2017 12:36:51 -0700 Message-ID: Subject: Re: [PATCH v2] ext4: have ext4_xattr_set_handle() allocate journal credits To: Andreas Dilger Cc: "Theodore Ts'o" , Ext4 Developers List , lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1153 Lines: 26 > One problem with this approach is that restarting the transaction handle will > make the xattr update non-atomic, which could be a real problem for some > workloads. For example, ACLs or SELinux or fscrypt xattrs being added in > a separate transaction from file creation, or being modified (delete in a > separate transaction from add) and then lost completely if the system crashes > before the second transaction is committed. Agreed. > It isn't clear to me why using the current helper function to precompute the > required transaction credits doesn't get this right in the first place? It > would just need to add the xattr credits to the original journal handle? An example code path is this: ext4_mkdir() ext4_new_inode_start_handle() __ext4_new_inode() <<== transaction handle is started here ext4_init_acl() __ext4_set_acl() ext4_xattr_set_handle() In this case, __ext4_new_inode() needs to figure out all journal credits needed including the ones for ext4_xattr_set_handle(). This is a few levels deep so reaching out to ext4_xattr_set_credits() with the right parameters is where the complexity lies.