[lustre-devel] mdc_resource_inode_free()
Andreas Dilger
adilger at whamcloud.com
Wed Dec 30 16:52:21 PST 2020
On Dec 22, 2020, at 13:25, Sudheendra Sampath <sudheendra.sampath at gmail.com<mailto:sudheendra.sampath at gmail.com>> wrote:
Hi,
I was trying to understand more about LDLM, specifically Lock Value Block (LVB's) and stumbled upon the following code block :
static int mdc_resource_inode_free(struct ldlm_resource *res)
{
if (res->lr_lvb_inode)
res->lr_lvb_inode = NULL;
return 0;
}
Shouldn't the pointer (lr_lvb_inode) be freed before assigning it to NULL ?
Just curious to know.
The "lr_lvb_inode" pointer is a pointer to the VFS inode that is referencing a lock/resource:
int mdc_set_lock_data(struct obd_export *exp, const struct lustre_handle *lockh,
void *data, __u64 *bits)
{
struct inode *new_inode = data;
:
lock->l_resource->lr_lvb_inode = new_inode;
}
The inode is allocated/freed separately by the VFS. The lr_lvb_inode pointer is used to quickly find the VFS inode from a DLM resource, but does not take a reference on the inode itself. Otherwise, the inode would always have an elevated reference count and would never be freed by the VFS.
Cheers, Andreas
--
Andreas Dilger
Principal Lustre Architect
Whamcloud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20201231/9fc17c49/attachment.html>
More information about the lustre-devel
mailing list