From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [PATCH v2] hfsplus: add HFSX subfolder count support Date: Fri, 7 Feb 2014 13:22:30 -0800 Message-ID: <20140207132230.aa01dea8a75dbd3256a755ed@linux-foundation.org> References: <1391801759-2979-1-git-send-email-saproj@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, Vyacheslav Dubeyko , Al Viro , Christoph Hellwig To: Sergei Antonov Return-path: Received: from mail.linuxfoundation.org ([140.211.169.12]:59289 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751446AbaBGVWc (ORCPT ); Fri, 7 Feb 2014 16:22:32 -0500 In-Reply-To: <1391801759-2979-1-git-send-email-saproj@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, 7 Feb 2014 20:35:59 +0100 Sergei Antonov wrote: > This patch adds support for HFSX 'HasFolderCount' flag and a corresponding > 'folderCount' field in folder records. (For reference see HFS_FOLDERCOUNT > and kHFSHasFolderCountBit/kHFSHasFolderCountMask in Apple's source code.) > > Ignoring subfolder count leads to fs errors found by Mac: > ... > Checking catalog hierarchy. > HasFolderCount flag needs to be set (id = 105) > (It should be 0x10 instead of 0) > Incorrect folder count in a directory (id = 2) > (It should be 7 instead of 6) > ... > > Steps to reproduce: > Format with "newfs_hfs -s /dev/diskXXX". > Mount in Linux. > Create a new directory in root. > Unmount. > Run "fsck_hfs /dev/diskXXX". > > The patch handles directory creation, deletion, and rename. > > @@ -203,6 +205,36 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid, > return hfs_brec_find(fd, hfs_find_rec_by_key); > } > > +static void hfsplus_subfolders_inc(struct inode *dir) > +{ > + struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb); > + > + if (test_bit(HFSPLUS_SB_HFSX, &sbi->flags)) { > + /* > + * Increment subfolder count. Note, the value is only meaningful > + * for folders with HFSPLUS_HAS_FOLDER_COUNT flag set. > + */ > + HFSPLUS_I(dir)->subfolders++; > + } > +} > + > +static void hfsplus_subfolders_dec(struct inode *dir) > +{ > + struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb); > + > + if (test_bit(HFSPLUS_SB_HFSX, &sbi->flags)) { > + /* > + * Decrement subfolder count. Note, the value is only meaningful > + * for folders with HFSPLUS_HAS_FOLDER_COUNT flag set. > + * > + * Check for zero. Some subfolders may have been created > + * by an implementation ignorant of this counter. > + */ > + if (HFSPLUS_I(dir)->subfolders) > + HFSPLUS_I(dir)->subfolders--; > + } > +} > + Two of hfsplus_rename_cat()'s callers hold vh_mutex, hfsplus_rename() does not. Which lock is preventing the obvious races here?