Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753282Ab2KFWZU (ORCPT ); Tue, 6 Nov 2012 17:25:20 -0500 Received: from twin.jikos.cz ([89.185.236.188]:49312 "EHLO twin.jikos.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751561Ab2KFWZS (ORCPT ); Tue, 6 Nov 2012 17:25:18 -0500 Date: Tue, 6 Nov 2012 23:24:42 +0100 From: David Sterba To: zwu.kernel@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, linuxram@linux.vnet.ibm.com, viro@zeniv.linux.org.uk, david@fromorbit.com, tytso@mit.edu, cmm@us.ibm.com, wuzhy@linux.vnet.ibm.com, wenqing.lz@taobao.com Subject: Re: [RFC v4+ hot_track 02/19] vfs: initialize and free data structures Message-ID: <20121106222442.GS3102@twin.jikos.cz> Reply-To: dave@jikos.cz Mail-Followup-To: zwu.kernel@gmail.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, linuxram@linux.vnet.ibm.com, viro@zeniv.linux.org.uk, david@fromorbit.com, tytso@mit.edu, cmm@us.ibm.com, wuzhy@linux.vnet.ibm.com, wenqing.lz@taobao.com References: <1351485061-12297-1-git-send-email-zwu.kernel@gmail.com> <1351485061-12297-3-git-send-email-zwu.kernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1351485061-12297-3-git-send-email-zwu.kernel@gmail.com> User-Agent: Mutt/1.5.21 (2011-07-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2484 Lines: 90 On Mon, Oct 29, 2012 at 12:30:44PM +0800, zwu.kernel@gmail.com wrote: > +/* Frees the entire hot_range_tree. */ > +static void hot_inode_item_free(struct kref *kref) > +{ > + struct hot_comm_item *comm_item = container_of(kref, > + struct hot_comm_item, refs); > + struct hot_inode_item *he = container_of(comm_item, > + struct hot_inode_item, hot_inode); > + > + hot_range_tree_free(he); > + radix_tree_delete(he->hot_inode_tree, he->i_ino); void *radix_tree_delete(struct radix_tree_root *root, unsigned long index) and he::i_ino is u64, this will not work when sizeof(unsigned long) != sizeof(u64) (iirc this is a known limitation of radix tree implementation). This will work on 64bit only, not sure if this is intentional. > + kmem_cache_free(hot_inode_item_cachep, he); > +} > + > +/* Frees the entire hot_inode_tree. */ > +static void hot_inode_tree_exit(struct hot_info *root) > +{ > + struct hot_inode_item *hi_nodes[8]; > + u64 ino = 0; > + int i, n; nitpick, put the declarations on separate lines > + > + while (1) { > + spin_lock(&root->lock); > + n = radix_tree_gang_lookup(&root->hot_inode_tree, > + (void **)hi_nodes, ino, > + ARRAY_SIZE(hi_nodes)); > + if (!n) { > + spin_unlock(&root->lock); > + break; > + } > + > + ino = hi_nodes[n - 1]->i_ino + 1; > + for (i = 0; i < n; i++) > + hot_inode_item_put(hi_nodes[i]); > + spin_unlock(&root->lock); > + } > +} > + > /* > * Initialize kmem cache for hot_inode_item and hot_range_item. > */ > @@ -106,3 +197,36 @@ err: > kmem_cache_destroy(hot_inode_item_cachep); > } > EXPORT_SYMBOL_GPL(hot_cache_init); > + > +/* > + * Initialize the data structures for hot data tracking. > + */ > +int hot_track_init(struct super_block *sb) > +{ > + struct hot_info *root; > + int ret = -ENOMEM; > + > + root = kzalloc(sizeof(struct hot_info), GFP_NOFS); > + if (!root) { > + printk(KERN_ERR "%s: Failed to malloc memory for " > + "hot_info\n", __func__); > + return ret; minor: you can drop the variable ret and just reurn ENOMEM here > + } > + > + sb->s_hot_root = root; > + hot_inode_tree_init(root); > + > + printk(KERN_INFO "VFS: Turning on hot data tracking\n"); > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(hot_track_init); david -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/