<commit_before>/*
 *  linux/fs/hfsplus/super.c
 *
 * Copyright (C) 2001
 * <NAME> (<EMAIL>)
 * (C) 2003 Ardis Technologies <<EMAIL>>
 *
 */

#include <linux/config.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/pagemap.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/version.h>
#include <linux/vfs.h>
#include <linux/nls.h>

static struct inode *hfsplus_alloc_inode(struct super_block *sb);
static void hfsplus_destroy_inode(struct inode *inode);

#include "hfsplus_fs.h"

void hfsplus_inode_check(struct super_block *sb)
{
#if 0
	u32 cnt = atomic_read(&HFSPLUS_SB(sb).inode_cnt);
	u32 last_cnt = HFSPLUS_SB(sb).last_inode_cnt;

	if (cnt <= (last_cnt / 2) ||
	    cnt >= (last_cnt * 2)) {
		HFSPLUS_SB(sb).last_inode_cnt = cnt;
		printk("inode_check: %u,%u,%u\n", cnt, last_cnt,
			HFSPLUS_SB(sb).cat_tree ? HFSPLUS_SB(sb).cat_tree->node_hash_cnt : 0);
	}
#endif
}

static void hfsplus_read_inode(struct inode *inode)
{
	struct hfs_find_data fd;
	struct hfsplus_vh *vhdr;
	int err;

	atomic_inc(&HFSPLUS_SB(inode->i_sb).inode_cnt);
	hfsplus_inode_check(inode->i_sb);
	INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list);
	init_MUTEX(&HFSPLUS_I(inode).extents_lock);
	HFSPLUS_I(inode).flags = 0;
	HFSPLUS_I(inode).rsrc_inode = NULL;

	if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
	read_inode:
		hfs_find_init(HFSPLUS_SB(inode->i_sb).cat_tree, &fd);
		err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
		if (!err)
			err = hfsplus_cat_read_inode(inode, &fd);
		hfs_find_exit(&fd);
		if (err)
			goto bad_inode;
		return;
	}
	vhdr = HFSPLUS_SB(inode->i_sb).s_vhdr;<commit_msg>[PATCH] Fix HFS+ to free up the space when a file is deleted.<commit_after>/*
 *  linux/fs/hfsplus/super.c
 *
 * Copyright (C) 2001
 * <NAME> (<EMAIL>)
 * (C) 2003 Ardis Technologies <<EMAIL>>
 *
 */

#include <linux/config.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/pagemap.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/version.h>
#include <linux/vfs.h>
#include <linux/nls.h>

static struct inode *hfsplus_alloc_inode(struct super_block *sb);
static void hfsplus_destroy_inode(struct inode *inode);

#include "hfsplus_fs.h"

void hfsplus_inode_check(struct super_block *sb)
{
#if 0
	u32 cnt = atomic_read(&HFSPLUS_SB(sb).inode_cnt);
	u32 last_cnt = HFSPLUS_SB(sb).last_inode_cnt;

	if (cnt <= (last_cnt / 2) ||
	    cnt >= (last_cnt * 2)) {
		HFSPLUS_SB(sb).last_inode_cnt = cnt;
		printk("inode_check: %u,%u,%u\n", cnt, last_cnt,
			HFSPLUS_SB(sb).cat_tree ? HFSPLUS_SB(sb).cat_tree->node_hash_cnt : 0);
	}
#endif
}

static void hfsplus_read_inode(struct inode *inode)
{
	struct hfs_find_data fd;
	struct hfsplus_vh *vhdr;
	int err;

	atomic_inc(&HFSPLUS_SB(inode->i_sb).inode_cnt);
	hfsplus_inode_check(inode->i_sb);
	INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list);
	init_MUTEX(&HFSPLUS_I(inode).extents_lock);
	HFSPLUS_I(inode).flags = 0;
	HFSPLUS_I(inode).rsrc_inode = NULL;
	atomic_set(&HFSPLUS_I(inode).opencnt, 0);

	if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
	read_inode:
		hfs_find_init(HFSPLUS_SB(inode->i_sb).cat_tree, &fd);
		err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
		if (!err)
			err = hfsplus_cat_read_inode(inode, &fd);
		hfs_find_exit(&fd);
		if (err)
			goto bad_inode;
		return;
	}
	vhdr = HFSPLUS_SB(inode->i_sb).s_vhdr;
{'fraction_non_alphanumeric': 0.157816671610798, 'fraction_numerical': 0.010382675763868289, 'mean_word_length': 5.291044776119403, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1502522', 'n_tokens_mistral': 1593, 'n_tokens_neox': 1488, 'n_words': 249}