[Lustre-devel] LNET:where in the code dose the file obeject's private data gets filled up.
Liang Zhen
Zhen.Liang at Sun.COM
Tue May 25 22:21:18 PDT 2010
ankit sharma wrote:
> Hi all,
> I am new to Lustre code. So i am sorry if my question is
> trivial or silly.
>
> My question:
>
> On line number 116 of the file lnet/lnet/router_proc.c
> variable ver_p is getting set from the proc file object's private data.
>
> Can any one tell me which part of the lustre code dose this file
> object private data
> gets initialized / set .
>
> conceptually in can imagine it should (correct me if I am worng) be
> set in open call of the file ( /proc/sys/lnet/routers )
>
> BUT I cant locate the Lustre code that dose that(sets the private data
> of file object).
>
>
> code snippet form lnet/lnet/router_proc.c
>
> int LL_PROC_PROTO(proc_lnet_routes)
> {
> int rc = 0;
> char *tmpstr;
> char *s;
> const int tmpsiz = 256;
> int len;
> int *ver_p = (unsigned int *)(&filp->private_data);
>
> DECLARE_LL_PROC_PPOS_DECL;
>
> LASSERT (!write);
>
> if (*lenp == 0)
> return 0;
>
> LIBCFS_ALLOC(tmpstr, tmpsiz);
> if (tmpstr == NULL)
> return -ENOMEM;
>
> s = tmpstr; /* points to current position in tmpstr[] */
>
> if (*ppos == 0) {
> s += snprintf(s, tmpstr + tmpsiz - s, "Routing %s\n",
> the_lnet.ln_routing ? "enabled" :
> "disabled");
> LASSERT (tmpstr + tmpsiz - s > 0);
>
> s += snprintf(s, tmpstr + tmpsiz - s, "%-8s %4s %7s %s\n",
> "net", "hops", "state", "router");
> LASSERT (tmpstr + tmpsiz - s > 0);
>
> LNET_LOCK();
> *ver_p = (unsigned int)the_lnet.ln_remote_nets_version;
It's initialized at here, because we have "*ppos == 0" while starting,
so it's actually same as
filp->private_data = (void *)the_lnet.ln_remote_nets_version;
Regards
Liang
> LNET_UNLOCK();
>
> } else {
> struct list_head *n;
> struct list_head *r;
> lnet_route_t *route = NULL;
> lnet_remotenet_t *rnet = NULL;
> int skip = *ppos - 1;
>
> LNET_LOCK();
>
> if (*ver_p != (unsigned
> int)the_lnet.ln_remote_nets_version) {
> LNET_UNLOCK();
> LIBCFS_FREE(tmpstr, tmpsiz);
> return -ESTALE;
> }
>
> n = the_lnet.ln_remote_nets.next;
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Lustre-devel mailing list
> Lustre-devel at lists.lustre.org
> http://lists.lustre.org/mailman/listinfo/lustre-devel
>
More information about the lustre-devel
mailing list