From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot0-f174.google.com ([74.125.82.174]:33730 "EHLO mail-ot0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751876AbdFIN37 (ORCPT ); Fri, 9 Jun 2017 09:29:59 -0400 Received: by mail-ot0-f174.google.com with SMTP id k4so38827042otd.0 for ; Fri, 09 Jun 2017 06:29:59 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1496821884-5178-1-git-send-email-amir73il@gmail.com> <1496821884-5178-9-git-send-email-amir73il@gmail.com> From: Miklos Szeredi Date: Fri, 9 Jun 2017 15:29:58 +0200 Message-ID: Subject: Re: [PATCH v2 08/20] ovl: lookup index entry for non-dir To: Amir Goldstein Cc: Al Viro , "linux-unionfs@vger.kernel.org" , linux-fsdevel Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Jun 9, 2017 at 3:24 PM, Amir Goldstein wrote: > On Fri, Jun 9, 2017 at 4:14 PM, Miklos Szeredi wrote: >> On Fri, Jun 9, 2017 at 1:49 PM, Miklos Szeredi wrote: >>> On Fri, Jun 9, 2017 at 11:38 AM, Amir Goldstein wrote: >> >>> The challenge is in accounting the number of link-ups atomically with >>> the link-up itself. No ideas off-hand. >> >> Following would work I think: >> >> - copy up to indexdir (it now has st_nlink == 1) >> - set overlay.nlinkup to "1-2" >> + the first number indicates the target number of linkups >> + the second indicates the target st_nlink on the file >> - fsync the file (hopefully this writes the xattrs as well as the data) >> - link the file from indexdir to upper >> - set overlay.nlinkup to "1" >> + this indicates that the linkup was finished and number of linkups is 1. >> >> There are 3 cases when we find a file with overlay.nlinkup: >> >> - just one number: nothing to do >> - two numbers and second number == st_nlink: replace with just the linkup value >> - two numbers and second number != st_nlink: replace with decremented >> linkup value >> >> So the atomicity is guaranteed by st_nlink becoming in sync with the >> target value. >> >> Would need to ensure that ovl_link() is not performed in parallel with >> the linkup procedure. >> > > Yep, I started to write you the same thing :) > I though of using a separate xattr for the transnational values, > and delete it after link up, but I guess single xattr is cleaner ?? > > I guess the new ovl_inode mutex could be used for blocking ovl_link(). > > Just to be clear: > - we are going to allocate ovl_inode from our own slab cache > - move from using the i_private inode fields to ovl_inode fields: > {realinode, originode, nlinkup, lock} > - use ovl_inode mutex instead of wait queue and for hardlink up > > Correct? Sounds good. Thanks, Miklos