ankit sharma
2010-May-25 18:07 UTC
[Lustre-devel] LNET:where in the code dose the file obeject''s private data gets filled up.
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; 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; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.lustre.org/pipermail/lustre-devel/attachments/20100525/7af34465/attachment.html
Andreas Dilger
2010-May-25 20:04 UTC
[Lustre-devel] LNET:where in the code dose the file obeject''s private data gets filled up.
On 2010-05-25, at 12:07, ankit sharma wrote:> 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).If this is related to porting Lustre to a newer kernel, please search bugzilla for the RHEL6 and/or SLES11 SP1 kernel patches, since it fixes up this bit of code already. Cheers, Andreas -- Andreas Dilger Lustre Technical Lead Oracle Corporation Canada Inc.
Liang Zhen
2010-May-26 05:21 UTC
[Lustre-devel] LNET:where in the code dose the file obeject''s private data gets filled up.
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 >