<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
On Dec 22, 2020, at 13:25, Sudheendra Sampath <<a href="mailto:sudheendra.sampath@gmail.com" class="">sudheendra.sampath@gmail.com</a>> wrote:<br class="">
<div>
<blockquote type="cite" class=""><br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Hi,
<div class=""><br class="">
</div>
<div class="">I was trying to understand more about LDLM, specifically Lock Value Block (LVB's) and stumbled upon the following code block :</div>
<div class=""><br class="">
</div>
<div class="">static int mdc_resource_inode_free(struct ldlm_resource *res)<br class="">
{<br class="">
        if (res->lr_lvb_inode)<br class="">
                res->lr_lvb_inode = NULL;<br class="">
<br class="">
        return 0;<br class="">
}<br class="">
<div class=""><br class="">
</div>
<div class="">Shouldn't the pointer (lr_lvb_inode) be freed before assigning it to NULL ?  </div>
<div class=""><br class="">
</div>
<div class="">Just curious to know.</div>
</div>
</div>
</div>
</blockquote>
<br class="">
</div>
<div>The "lr_lvb_inode" pointer is a pointer to the VFS inode that is referencing a lock/resource:</div>
<div><br class="">
</div>
<div>int mdc_set_lock_data(struct obd_export *exp, const struct lustre_handle *lockh,<br class="">
                      void *data, __u64 *bits)<br class="">
{</div>
<div>        struct inode *new_inode = data;<br class="">
</div>
<div>        :</div>
<div>        lock->l_resource->lr_lvb_inode = new_inode;</div>
<div>}</div>
<div><br class="">
</div>
<div>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.</div>
<div><br class="">
</div>
<div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div>Cheers, Andreas</div>
<div>--</div>
<div>Andreas Dilger</div>
<div>Principal Lustre Architect</div>
<div>Whamcloud</div>
<div><br class="">
</div>
<div><br class="">
</div>
<div><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
<br class="Apple-interchange-newline">
<br class="Apple-interchange-newline">
</div>
<br class="">
</body>
</html>