<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Sep 14, 2021, at 12:34 AM, Gang He <<a href="mailto:ghe@suse.com" class="">ghe@suse.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Hi Wengang,<br class="">
<br class="">
Sorry for delayed reply.<br class="">
<br class="">
On 2021/9/9 0:00, Wengang Wang wrote:<br class="">
<blockquote type="cite" class="">
<blockquote type="cite" class="">On Sep 7, 2021, at 11:06 PM, Gang He <<a href="mailto:ghe@suse.com" class="">ghe@suse.com</a>> wrote:<br class="">
<br class="">
<br class="">
<br class="">
On 2021/9/7 23:57, Wengang Wang wrote:<br class="">
<blockquote type="cite" class="">Hi Gang,<br class="">
Sure, I will look into the problem you are trying to address. Any bug fix and performance improvement is welcomed!<br class="">
Well, can you please provide the analysis on the tcpdumps between the (two) nodes that covers the reflink operation with/without your patch to show how you saved dlm locking ping-pongs?<br class="">
</blockquote>
The code change will hold the reflink destination dir inode dlm lock, release it until the whole reflink process is completed.<br class="">
The current code will hold/release this dlm lock three times during the reflink process. If there are some concurrently reflink operation to that directory from other nodes, the ping-pong effect is that directory inode related data will be synchronized(multiple
times) to the disk when inode dlm lock is downconverted during one reflink operation.<br class="">
<br class="">
</blockquote>
I think the above can be a good summary, but not details or the locking ping-pong procedure. I need the details to understand the situation. For details, Which locks are involved, what are the locking types, which nodes are involved.<br class="">
</blockquote>
<br class="">
The problem is clone files to the same directory simultaneously, for some users, they like to add this task to each node as a crontab job.<br class="">
The main impact factor is the destination dir inode dlm lock in this case, each reflink operation will acquire/release this dlm lock three time. For parallel environment, each node will contend this dlm lock, that means there will be some lock downconvert costs(sync
the inode meta-data to the disk before downconvert).<br class="">
For the code logic, I think we can identify this problem clearly,I<br class="">
do not think we need performance related tool to help us.<br class="">
Here, I can share my test results for clone files to the same directory simultaneously.<br class="">
1) test script on each node: <a href="https://pastebin.com/y8EcCjWK" class="">https://pastebin.com/y8EcCjWK</a><br class="">
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>I am pasting your test script here:</div>
<div><br class="">
</div>
<div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(168, 169, 35);" class=""> 1
</span><span style="font-variant-ligatures: no-common-ligatures;" class="">loop=1</span></span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #a8a923" class=""> 2
</span><span style="font-variant-ligatures: no-common-ligatures" class="">while ((loop++)) ; do</span></span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(168, 169, 35);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class=""> 3 </span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #a8a923" class=""> 4
</span><span style="font-variant-ligatures: no-common-ligatures" class=""> for i in `seq 1 100`; do</span></span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #a8a923" class=""> 5
</span><span style="font-variant-ligatures: no-common-ligatures" class=""> reflink "/mnt/shared/testnode1.qcow2" "/mnt/shared/.snapshots/testnode1.qcow2.${loop}.${i}.`date +%m%d%H%M%S`.`hostname`"</span></span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #a8a923" class=""> 6
</span><span style="font-variant-ligatures: no-common-ligatures" class=""> done</span></span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(168, 169, 35);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class=""> 7 </span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #a8a923" class=""> 8
</span><span style="font-variant-ligatures: no-common-ligatures" class=""> rm -f /mnt/shared/.snapshots/testnode1.qcow2.*.`hostname`</span></span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #a8a923" class=""> 9
</span><span style="font-variant-ligatures: no-common-ligatures" class=""> echo "`hostname` `date +%m%d%H%M%S`: loop - $loop"</span></span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="background-color: rgb(255, 255, 255);" class=""><span style="text-decoration: underline; font-variant-ligatures: no-common-ligatures; color: rgb(235, 238, 23);" class=""> 10
</span><span style="text-decoration: underline; font-variant-ligatures: no-common-ligatures;" class="">done </span></span></div>
</div>
<div><br class="">
</div>
<div>I think your test script would heavily depends on the size of file testnode1.qcow2 and how fragmented it is. That would impact the number of extent records to be copied.</div>
<div>Let’s simplify the reflink procedure with your patch applied:</div>
<div><br class="">
</div>
<div>1) lock destination dir</div>
<div>2) extent record copy</div>
<div>3) unlock destination dir</div>
<div><br class="">
</div>
<div>Apply this to multinode case:</div>
<div><br class="">
</div>
<div>node1 node2 node3</div>
<div>
<div style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "Helvetica Neue";" class="">
———— ———— ————</div>
</div>
<div>lock</div>
<div>extent copy</div>
<div>unlock</div>
<div><br class="">
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> lock</div>
<div> extent copy</div>
<div> unlock</div>
<div><br class="">
</div>
<div> lock</div>
<div> extent copy</div>
<div> unlock</div>
<div><br class="">
</div>
<div><br class="">
</div>
<div>As you said, you saved the time of down-converting by serializing the reflink opertions targeting the directory. But seems you skipped the impact of extent copy.</div>
<div>If extent copy take much more time than lock down-convertings, your patch may slowdown the whole reflink operations among the three nodes.</div>
<div>The time for extent copy depends:</div>
<div>a) number of extents to copy. more extents more time</div>
<div>b) CPUs load on the nodes, higher CPU load more time</div>
<div>c) OCFS2 device load, higher load more time</div>
<div><br class="">
</div>
<div>I don’t know if you considered above factors when you did your test. I was ever playing reflink with well fragmented 50GB file (though it’s not OCFS2). When load is added, a single run of reflink take 20+m.</div>
<div>So I’d like to see your test for at least this case:</div>
<div>I) make the reflink source file 50GiB long (with FS cluster size 1MiB) and</div>
<div>II) make the reflink source file well fragmented (suggest 40% fragmentation) and</div>
<div>III) add some CPU and block device load and</div>
<div>IV) add some file creation/removal operations under the same destination directory as the reflinks do, and collect the time for each operations. Do it on all the three nodes. </div>
<div><br class="">
</div>
<div>For II), I’d suggest 40% fragmentation ratio, some example output and time for reflinks</div>
<div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">debugfs: frag /file1</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">Inode: 592130<span class="Apple-tab-span" style="white-space: pre;">
</span>% fragmented: 40.00<span class="Apple-tab-span" style="white-space: pre;">
</span>clusters: 51200<span class="Apple-tab-span" style="white-space: pre;"> </span>
extents: 20481<span class="Apple-tab-span" style="white-space: pre;"> </span>score: 40</span></div>
</div>
<div><br class="">
</div>
<div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">[root@wengwan-ocfs2-3 opc]# time reflink /ocfs2/file1 /ocfs2/dir1/reflink1</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17); min-height: 14px;" class="">
<span style="background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class="">
</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">real<span class="Apple-tab-span" style="white-space:pre">
</span>0m6.837s</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">user<span class="Apple-tab-span" style="white-space:pre">
</span>0m0.000s</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">sys<span class="Apple-tab-span" style="white-space:pre">
</span>0m6.828s</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">[root@wengwan-ocfs2-3 opc]# time reflink /ocfs2/file1 /ocfs2/dir1/reflink2</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17); min-height: 14px;" class="">
<span style="background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class="">
</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">real<span class="Apple-tab-span" style="white-space:pre">
</span>0m3.799s</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">user<span class="Apple-tab-span" style="white-space:pre">
</span>0m0.000s</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">sys<span class="Apple-tab-span" style="white-space:pre">
</span>0m3.799s</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">[root@wengwan-ocfs2-3 opc]# time reflink /ocfs2/file1 /ocfs2/dir1/reflink3</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17); min-height: 14px;" class="">
<span style="background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class="">
</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">real<span class="Apple-tab-span" style="white-space:pre">
</span>0m3.802s</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">user<span class="Apple-tab-span" style="white-space:pre">
</span>0m0.001s</span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(32, 146, 17);" class="">
<span style="font-variant-ligatures: no-common-ligatures; background-color: rgb(255, 255, 255);" class="">sys<span class="Apple-tab-span" style="white-space:pre">
</span>0m3.801s</span></div>
</div>
<div><br class="">
</div>
<div>I’d guess you may get negative result comparing to original kernel for both reflink and file creation/removal.</div>
<div><br class="">
</div>
<div>thanks,</div>
<div>wengang</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div class="">2) Performance log of current parallel reflink:<br class="">
<a href="https://pastebin.com/qGSedy8E" class="">https://pastebin.com/qGSedy8E</a><br class="">
3) Performance log of parallel reflink after patching:<br class="">
<a href="https://pastebin.com/xkyxtNU4" class="">https://pastebin.com/xkyxtNU4</a><br class="">
<br class="">
For the performance logs, the test time has been cut in half for every hundred reflink operations.<br class="">
<br class="">
In sum, I think this code change logic is simple and clear, can improve<br class="">
the performance in the above case. Of course, I also want more people to review if there is any risk after this patch, e.g. add dead-lock risk, etc.<br class="">
<br class="">
<br class="">
<br class="">
Thanks<br class="">
Gang<br class="">
<br class="">
<br class="">
<blockquote type="cite" class="">Say like this (just for an example, not related to the problem here):<br class="">
Node 1 Node 2 Node 3<br class="">
——————————— ——————————— ————————————————————<br class="">
dir1 meta lock EX<br class="">
orphandir1 lock EX<br class="">
dir1 meta lock EX<br class="">
orphadir2 lock EX<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> dir1
meta lock EX<br class="">
orphadir3 lock EX<br class="">
dir1 meta block EX (again)<br class="">
………………..<br class="">
<blockquote type="cite" class="">According to my test, running the reflink command to clone a file to the same directory repeatedly from three nodes, the code change can shorten the previous half of the time.<br class="">
<br class="">
</blockquote>
I am not sure if above is a typical use case.<br class="">
What else cases did you test? Did it help in case only one node do the reflink?<br class="">
What if there are concurrent file creating/removing operations going on under the target directory when the reflink is going on?<br class="">
I think when you are trying to make a performance improvement, you should provide the performance data for different test cases, like this:<br class="">
————————————————————————————————<br class="">
Test case desc | orig performance | performance after patched |<br class="">
————————————————————————————————<br class="">
test case1 (details) | perf data | perf data |<br class="">
———————————————————————————————-<br class="">
test case2 (details) | perf data | perf data |<br class="">
———————————————————————————————<br class="">
……<br class="">
thanks,<br class="">
wengang<br class="">
<blockquote type="cite" class="">Thanks<br class="">
Gang<br class="">
<br class="">
<blockquote type="cite" class="">And what cases did you test to get better performance?<br class="">
thanks,<br class="">
wengang<br class="">
<blockquote type="cite" class="">On Aug 30, 2021, at 11:25 PM, Gang He <<a href="mailto:ghe@suse.com" class="">ghe@suse.com</a>> wrote:<br class="">
<br class="">
Hello Joseph and Wengang,<br class="">
<br class="">
When you have time, please help review this patch.<br class="">
About the deadlock problem which was caused by ocfs2_downconvert_lock<br class="">
failure, we have the fix patch, it is very key.<br class="">
But I feel this patch is still useful as a optimization patch, the user<br class="">
case is to reflink the files to the same directory concurrently, our<br class="">
users usually backup the files(via reflink) from the cluster nodes<br class="">
concurrently(via crontab) every day/hour.<br class="">
The current design, during the reflink process, the node will<br class="">
acquire/release dlm lock of the target directory multiple times,<br class="">
this is very inefficient in concurrently reflink.<br class="">
<br class="">
<br class="">
Thanks<br class="">
Gang<br class="">
<br class="">
On 2021/8/26 15:59, Gang He wrote:<br class="">
<blockquote type="cite" class="">During the reflink process, we should acquire the target directory<br class="">
inode dlm lock at the beginning, and hold this dlm lock until end<br class="">
of the function.<br class="">
With this patch, we avoid dlm lock ping-pong effect when clone<br class="">
files to the same directory simultaneously from multiple nodes.<br class="">
There is a typical user scenario, users regularly back up files<br class="">
to a specified directory through the reflink feature from the<br class="">
multiple nodes.<br class="">
<br class="">
Signed-off-by: Gang He <<a href="mailto:ghe@suse.com" class="">ghe@suse.com</a>><br class="">
---<br class="">
fs/ocfs2/namei.c | 32 +++++++++++++-------------------<br class="">
fs/ocfs2/namei.h | 2 ++<br class="">
fs/ocfs2/refcounttree.c | 15 +++++++++++----<br class="">
fs/ocfs2/xattr.c | 12 +-----------<br class="">
fs/ocfs2/xattr.h | 1 +<br class="">
5 files changed, 28 insertions(+), 34 deletions(-)<br class="">
<br class="">
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c<br class="">
index 2c46ff6ba4ea..f8bbb22cc60b 100644<br class="">
--- a/fs/ocfs2/namei.c<br class="">
+++ b/fs/ocfs2/namei.c<br class="">
@@ -2489,6 +2489,7 @@ static int ocfs2_prep_new_orphaned_file(struct inode *dir,<br class="">
}<br class="">
<br class="">
int ocfs2_create_inode_in_orphan(struct inode *dir,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>struct buffer_head
**dir_bh,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>int mode,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>struct inode **new_inode)<br class="">
{<br class="">
@@ -2597,13 +2598,16 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>brelse(new_di_bh);<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (!status)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>*new_inode = inode;<br class="">
-<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>ocfs2_free_dir_lookup_result(&orphan_insert);<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>ocfs2_inode_unlock(dir, 1);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>brelse(parent_di_bh);<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span>if (!status) {<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>*new_inode = inode;<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>*dir_bh = parent_di_bh;<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span>} else {<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ocfs2_inode_unlock(dir, 1);<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>brelse(parent_di_bh);<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">
+<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>return status;<br class="">
}<br class="">
<br class="">
@@ -2760,11 +2764,11 @@ int ocfs2_del_inode_from_orphan(struct ocfs2_super *osb,<br class="">
}<br class="">
<br class="">
int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> struct buffer_head
*dir_bh,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> struct inode
*inode,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> struct dentry
*dentry)<br class="">
{<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>int status = 0;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>struct buffer_head *parent_di_bh = NULL;<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>handle_t *handle = NULL;<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>struct ocfs2_dinode *dir_di, *di;<br class="">
@@ -2778,14 +2782,7 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>(unsigned long
long)OCFS2_I(dir)->ip_blkno,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>(unsigned long
long)OCFS2_I(inode)->ip_blkno);<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>status = ocfs2_inode_lock(dir, &parent_di_bh, 1);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (status < 0) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if (status != -ENOENT)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>mlog_errno(status);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return status;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">
-<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>dir_di = (struct ocfs2_dinode *) parent_di_bh->b_data;<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span>dir_di = (struct ocfs2_dinode *) dir_bh->b_data;<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>if (!dir_di->i_links_count) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>/* can't make a file in a deleted directory. */<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>status = -ENOENT;<br class="">
@@ -2798,7 +2795,7 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>goto leave;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>/* get a spot inside the dir. */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>status = ocfs2_prepare_dir_for_insert(osb, dir, parent_di_bh,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span>status = ocfs2_prepare_dir_for_insert(osb, dir, dir_bh,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> dentry->d_name.name,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> dentry->d_name.len,
&lookup);<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>if (status < 0) {<br class="">
@@ -2862,7 +2859,7 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>ocfs2_journal_dirty(handle, di_bh);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>status = ocfs2_add_entry(handle, dentry, inode,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>OCFS2_I(inode)->ip_blkno,
parent_di_bh,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>OCFS2_I(inode)->ip_blkno,
dir_bh,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&lookup);<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>if (status < 0) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>mlog_errno(status);<br class="">
@@ -2886,10 +2883,7 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>iput(orphan_dir_inode);<br class="">
leave:<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>ocfs2_inode_unlock(dir, 1);<br class="">
-<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>brelse(di_bh);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>brelse(parent_di_bh);<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>brelse(orphan_dir_bh);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>ocfs2_free_dir_lookup_result(&lookup);<br class="">
diff --git a/fs/ocfs2/namei.h b/fs/ocfs2/namei.h<br class="">
index 9cc891eb874e..03a2c526e2c1 100644<br class="">
--- a/fs/ocfs2/namei.h<br class="">
+++ b/fs/ocfs2/namei.h<br class="">
@@ -24,6 +24,7 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span> struct buffer_head *orphan_dir_bh,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span> bool dio);<br class="">
int ocfs2_create_inode_in_orphan(struct inode *dir,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>struct buffer_head
**dir_bh,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>int mode,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>struct inode **new_inode);<br class="">
int ocfs2_add_inode_to_orphan(struct ocfs2_super *osb,<br class="">
@@ -32,6 +33,7 @@ int ocfs2_del_inode_from_orphan(struct ocfs2_super *osb,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>struct inode *inode, struct buffer_head *di_bh,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>int update_isize, loff_t end);<br class="">
int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> struct buffer_head
*dir_bh,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> struct inode
*new_inode,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> struct dentry
*new_dentry);<br class="">
<br class="">
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c<br class="">
index 7f6355cbb587..a9a0c7c37e8e 100644<br class="">
--- a/fs/ocfs2/refcounttree.c<br class="">
+++ b/fs/ocfs2/refcounttree.c<br class="">
@@ -4250,7 +4250,7 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,<br class="">
{<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>int error, had_lock;<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>struct inode *inode = d_inode(old_dentry);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>struct buffer_head *old_bh = NULL;<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span>struct buffer_head *old_bh = NULL, *dir_bh = NULL;<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>struct inode *new_orphan_inode = NULL;<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>struct ocfs2_lock_holder oh;<br class="">
<br class="">
@@ -4258,7 +4258,7 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return -EOPNOTSUPP;<br class="">
<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>error = ocfs2_create_inode_in_orphan(dir, inode->i_mode,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span>error = ocfs2_create_inode_in_orphan(dir, &dir_bh, inode->i_mode,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> &new_orphan_inode);<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>if (error) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>mlog_errno(error);<br class="">
@@ -4304,13 +4304,15 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>/* If the security isn't preserved, we need to re-initialize them. */<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>if (!preserve) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>error = ocfs2_init_security_and_acl(dir, new_orphan_inode,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>error = ocfs2_init_security_and_acl(dir, dir_bh,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> new_orphan_inode,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> &new_dentry->d_name);<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if (error)<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>mlog_errno(error);<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>if (!error) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>error = ocfs2_mv_orphaned_inode_to_new(dir, new_orphan_inode,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>error = ocfs2_mv_orphaned_inode_to_new(dir, dir_bh,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> new_orphan_inode,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span> new_dentry);<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if (error)<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>mlog_errno(error);<br class="">
@@ -4328,6 +4330,11 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>iput(new_orphan_inode);<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">
<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span>if (dir_bh) {<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ocfs2_inode_unlock(dir, 1);<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>brelse(dir_bh);<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">
+<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>return error;<br class="">
}<br class="">
<br class="">
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c<br class="">
index dd784eb0cd7c..3f23e3a5018c 100644<br class="">
--- a/fs/ocfs2/xattr.c<br class="">
+++ b/fs/ocfs2/xattr.c<br class="">
@@ -7203,16 +7203,13 @@ int ocfs2_reflink_xattrs(struct inode *old_inode,<br class="">
/*<br class="">
* Initialize security and acl for a already created inode.<br class="">
* Used for reflink a non-preserve-security file.<br class="">
- *<br class="">
- * It uses common api like ocfs2_xattr_set, so the caller<br class="">
- * must not hold any lock expect i_mutex.<br class="">
*/<br class="">
int ocfs2_init_security_and_acl(struct inode *dir,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>struct buffer_head
*dir_bh,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>struct inode *inode,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>const struct qstr
*qstr)<br class="">
{<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>int ret = 0;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>struct buffer_head *dir_bh = NULL;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>ret = ocfs2_init_security_get(inode, dir, qstr, NULL);<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>if (ret) {<br class="">
@@ -7220,17 +7217,10 @@ int ocfs2_init_security_and_acl(struct inode *dir,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>goto leave;<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>ret = ocfs2_inode_lock(dir, &dir_bh, 0);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (ret) {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>mlog_errno(ret);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>goto leave;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>ret = ocfs2_init_acl(NULL, inode, dir, NULL, dir_bh, NULL, NULL);<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>if (ret)<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>mlog_errno(ret);<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>ocfs2_inode_unlock(dir, 0);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>brelse(dir_bh);<br class="">
leave:<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>return ret;<br class="">
}<br class="">
diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h<br class="">
index 00308b57f64f..b27fd8ba0019 100644<br class="">
--- a/fs/ocfs2/xattr.h<br class="">
+++ b/fs/ocfs2/xattr.h<br class="">
@@ -83,6 +83,7 @@ int ocfs2_reflink_xattrs(struct inode *old_inode,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>struct buffer_head *new_bh,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>bool preserve_security);<br class="">
int ocfs2_init_security_and_acl(struct inode *dir,<br class="">
+<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>struct buffer_head
*dir_bh,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>struct inode *inode,<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>const struct qstr
*qstr);<br class="">
#endif /* OCFS2_XATTR_H */<br class="">
<br class="">
</blockquote>
<br class="">
<br class="">
_______________________________________________<br class="">
Ocfs2-devel mailing list<br class="">
<a href="mailto:Ocfs2-devel@oss.oracle.com" class="">Ocfs2-devel@oss.oracle.com</a><br class="">
https://oss.oracle.com/mailman/listinfo/ocfs2-devel<br class="">
</blockquote>
</blockquote>
<br class="">
</blockquote>
</blockquote>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</body>
</html>