From: Andrew Morton <akpm@linux-foundation.org>
To: Sergei Antonov <saproj@gmail.com>
Cc: linux-fsdevel@vger.kernel.org,
Vyacheslav Dubeyko <slava@dubeyko.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH v2] hfsplus: add HFSX subfolder count support
Date: Fri, 7 Feb 2014 13:22:30 -0800 [thread overview]
Message-ID: <20140207132230.aa01dea8a75dbd3256a755ed@linux-foundation.org> (raw)
In-Reply-To: <1391801759-2979-1-git-send-email-saproj@gmail.com>
On Fri, 7 Feb 2014 20:35:59 +0100 Sergei Antonov <saproj@gmail.com> 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?
next prev parent reply other threads:[~2014-02-07 21:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-07 19:35 [PATCH v2] hfsplus: add HFSX subfolder count support Sergei Antonov
2014-02-07 21:22 ` Andrew Morton [this message]
2014-02-08 9:17 ` Sergei Antonov
2014-02-08 12:21 ` Vyacheslav Dubeyko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140207132230.aa01dea8a75dbd3256a755ed@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=saproj@gmail.com \
--cc=slava@dubeyko.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).