<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
Fair enough.&nbsp; It doesnt really make sense in context, but thats fine since its temporary.<br>
<br>
<br>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> James Simmons &lt;jsimmons@infradead.org&gt;<br>
<b>Sent:</b> Wednesday, August 1, 2018 10:52:21 PM<br>
<b>To:</b> Patrick Farrell<br>
<b>Cc:</b> Andreas Dilger; Oleg Drokin; NeilBrown; Lustre Development List<br>
<b>Subject:</b> Re: [PATCH 06/31] lustre: llite: reduce jobstats race window</font>
<div>&nbsp;</div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText"><br>
&gt; I'm puzzled, James - Why is &quot;cache_jobid&quot; in there?&nbsp; Isn't that from Ben Evans' work?&nbsp; This patch landed before all of that...<br>
<br>
All back ported patches have the potential to be modified so it can pass <br>
checkpatch as well as perfered standards. One of the common complaints <br>
was that lustre tends to use generic goto lables which can make grepping <br>
of the code more challenging. So I often change generic got lables to <br>
something with more meat. In this case I picked a nice name that came from <br>
a later patch :-)<br>
&nbsp;<br>
&gt; ______________________________________________________________________________________________________________________________<br>
&gt; From: James Simmons &lt;jsimmons@infradead.org&gt;<br>
&gt; Sent: Monday, July 30, 2018 9:25:58 PM<br>
&gt; To: Andreas Dilger; Oleg Drokin; NeilBrown<br>
&gt; Cc: Lustre Development List; Patrick Farrell; James Simmons<br>
&gt; Subject: [PATCH 06/31] lustre: llite: reduce jobstats race window &nbsp;<br>
&gt; From: Patrick Farrell &lt;paf@cray.com&gt;<br>
&gt; <br>
&gt; In the current code, lli_jobid is set to zero on every call<br>
&gt; to lustre_get_jobid.&nbsp; This causes problems, because it's<br>
&gt; used asynchronously to set the job id in RPCs, and some<br>
&gt; RPCs will falsely get no jobid set.&nbsp; (For small IO sizes,<br>
&gt; this can be up to 60% of RPCs.)<br>
&gt; <br>
&gt; It would be very expensive to put hard synchronization<br>
&gt; between this and every outbound RPC, and it's OK to very<br>
&gt; rarely get an RPC without correct job stats info.<br>
&gt; <br>
&gt; This patch only updates the lli_jobid when the job id has<br>
&gt; changed, which leaves only a very small window for reading<br>
&gt; an inconsistent job id.<br>
&gt; <br>
&gt; Signed-off-by: Patrick Farrell &lt;paf@cray.com&gt;<br>
&gt; WC-id: <a href="https://jira.whamcloud.com/browse/LU-8926">https://jira.whamcloud.com/browse/LU-8926</a><br>
&gt; Reviewed-on: <a href="https://review.whamcloud.com/24253">https://review.whamcloud.com/24253</a><br>
&gt; Reviewed-by: Andreas Dilger &lt;adilger@whamcloud.com&gt;<br>
&gt; Reviewed-by: Chris Horn &lt;hornc@cray.com&gt;<br>
&gt; Signed-off-by: James Simmons &lt;jsimmons@infradead.org&gt;<br>
&gt; ---<br>
&gt; &nbsp;drivers/staging/lustre/lustre/llite/llite_lib.c&nbsp;&nbsp;&nbsp; |&nbsp; 1 &#43;<br>
&gt; &nbsp;drivers/staging/lustre/lustre/obdclass/class_obd.c | 20 &#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;------<br>
&gt; &nbsp;2 files changed, 15 insertions(&#43;), 6 deletions(-)<br>
&gt; <br>
&gt; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c<br>
&gt; index c0861b9..72b118a 100644<br>
&gt; --- a/drivers/staging/lustre/lustre/llite/llite_lib.c<br>
&gt; &#43;&#43;&#43; b/drivers/staging/lustre/lustre/llite/llite_lib.c<br>
&gt; @@ -894,6 &#43;894,7 @@ void ll_lli_init(struct ll_inode_info *lli)<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lli-&gt;lli_async_rc = 0;<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mutex_init(&amp;lli-&gt;lli_layout_mutex);<br>
&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memset(lli-&gt;lli_jobid, 0, LUSTRE_JOBID_SIZE);<br>
&gt; &nbsp;}<br>
&gt; &nbsp;<br>
&gt; &nbsp;int ll_fill_super(struct super_block *sb)<br>
&gt; diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c<br>
&gt; index cdaf729..87327ef 100644<br>
&gt; --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c<br>
&gt; &#43;&#43;&#43; b/drivers/staging/lustre/lustre/obdclass/class_obd.c<br>
&gt; @@ -95,26 &#43;95,34 @@<br>
&gt; &nbsp; */<br>
&gt; &nbsp;int lustre_get_jobid(char *jobid)<br>
&gt; &nbsp;{<br>
&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memset(jobid, 0, LUSTRE_JOBID_SIZE);<br>
&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char tmp_jobid[LUSTRE_JOBID_SIZE] = { 0 };<br>
&gt; &#43;<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Jobstats isn't enabled */<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (strcmp(obd_jobid_var, JOBSTATS_DISABLE) == 0)<br>
&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>
&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto out_cache_jobid;<br>
&gt; &nbsp;<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Use process name &#43; fsuid as jobid */<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) {<br>
&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; snprintf(jobid, LUSTRE_JOBID_SIZE, &quot;%s.%u&quot;,<br>
&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; snprintf(tmp_jobid, LUSTRE_JOBID_SIZE, &quot;%s.%u&quot;,<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; current-&gt;comm,<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from_kuid(&amp;init_user_ns, current_fsuid()));<br>
&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>
&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto out_cache_jobid;<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&gt; &nbsp;<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Whole node dedicated to single job */<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (strcmp(obd_jobid_var, JOBSTATS_NODELOCAL) == 0) {<br>
&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strcpy(jobid, obd_jobid_node);<br>
&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>
&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strcpy(tmp_jobid, obd_jobid_node);<br>
&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto out_cache_jobid;<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&gt; &nbsp;<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -ENOENT;<br>
&gt; &#43;<br>
&gt; &#43;out_cache_jobid:<br>
&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Only replace the job ID if it changed. */<br>
&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (strcmp(jobid, tmp_jobid) != 0)<br>
&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strcpy(jobid, tmp_jobid);<br>
&gt; &#43;<br>
&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>
&gt; &nbsp;}<br>
&gt; &nbsp;EXPORT_SYMBOL(lustre_get_jobid);<br>
&gt; &nbsp;<br>
&gt; --<br>
&gt; 1.8.3.1<br>
&gt; <br>
&gt; <br>
&gt; </div>
</span></font></div>
</body>
</html>