[illumos-Developer] [RFC] Dead code in smbfs client

Garrett D'Amore garrett at nexenta.com
Tue May 17 22:59:23 PDT 2011


Usually I prefer to remove dead code, but usually some research is desirable first.  Why is this code dead?  Was it intended to be used?  Is there a bug that it is not used?  Are there plans to use it in the future?

Gordon Ross on our team was the main owner of this code, as I understand it, so I'd ask him for more details about this particular code.

  -- Garrett D'Amore

On May 17, 2011, at 9:16 PM, "Dan Kruchinin" <dkruchinin at acm.org> wrote:

> Hi list.
> 
> Pleas look at uts/common/fs/smbclnt/smbfs_node.h
> It contains definition of smbnode structure that contains a field:
>    cred_t        *r_cred;    /* current credentials */
> 
> This filed is accessed from four functions
> File uts/common/fs/smbclnt/smbfs_vnops.c
> 1) smbfs_open
> --
>    /*
>     * This thread did the open.
>     * Save our credentials too.
>     */
>    mutex_enter(&np->r_statelock);
>    oldcr = np->r_cred;
>    np->r_cred = cr;
>    crhold(cr);
>    if (oldcr)
>        crfree(oldcr);
>    mutex_exit(&np->r_statelock);
> --
> 
> 2) smbfs_rele_fid
> --
>    /*
>     * Other "last close" stuff.
>     */
>    mutex_enter(&np->r_statelock);
>    if (np->n_flag & NATTRCHANGED)
>        smbfs_attrcache_rm_locked(np);
>    oldcr = np->r_cred;
>    np->r_cred = NULL;
>    mutex_exit(&np->r_statelock);
>    if (oldcr != NULL)
>        crfree(oldcr);
> --
> 
> File uts/common/fs/smbclnt/smbfs/smbfs_subr2.c
> 1) sn_inactive
> --
>    oldcr = np->r_cred;
>    np->r_cred = NULL;
> ...
>    if (oldcr != NULL)
>        crfree(oldcr);
> 
> --
> 
> 2) sn_destroy_node
> --
>    ASSERT(np->r_cred == NULL);
> --
> 
> As you can see kernel just saves credentials of the last guy who
> opened file on smbfs share to r_cred field of smbfsnode and nothing
> more.
> It doesn't use saved credentials later even for debugging.
> 
> What illumos policy says about dead code? Should it be removed or dropped as is?
> 
> -- 
> W.B.R.
> Dan Kruchinin
> 
> _______________________________________________
> Developer mailing list
> Developer at lists.illumos.org
> http://lists.illumos.org/m/listinfo/developer



More information about the Developer mailing list