From: NeilBrown Date: Sun, 4 Nov 2018 20:26:57 +0000 (-0500) Subject: LU-11616 llite: replace smp_wb() with full memory barrier X-Git-Tag: 2.12.52~80 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=bdb2683fffa89ce31f43f5f42eed50e6d6dbb94b LU-11616 llite: replace smp_wb() with full memory barrier While porting the smp_mb() patch from LU-9210 to the linux clients Neil asked that the smp_wb() be replaced with the full memory barrier functions smp_store_release() and smp_load_acquire(). For this case _sa_make_ready() sets the entry->se_state and revalidate_statahead_dentry() tests the value of entry->se_state after waiting on sai_waitq. This change will make it obvious which variable was important, and would show the paired synchronization points. An additional benefit is that code will work on platforms that are not "total store order" TSO architectures like PowerPC. Change-Id: I687177bf1697a21db624a289c136215af4d90506 Signed-off-by: NeilBrown Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/33571 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Patrick Farrell Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c index 3977129..5c7dbb56 100644 --- a/lustre/llite/statahead.c +++ b/lustre/llite/statahead.c @@ -325,7 +325,11 @@ __sa_make_ready(struct ll_statahead_info *sai, struct sa_entry *entry, int ret) } } list_add(&entry->se_list, pos); - entry->se_state = ret < 0 ? SA_ENTRY_INVA : SA_ENTRY_SUCC; + /* + * LU-9210: ll_statahead_interpet must be able to see this before + * we wake it up + */ + smp_store_release(&entry->se_state, ret < 0 ? SA_ENTRY_INVA : SA_ENTRY_SUCC); return (index == sai->sai_index_wait); } @@ -767,7 +771,6 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, } sai->sai_replied++; - smp_mb(); if (waitq != NULL) wake_up(waitq); spin_unlock(&lli->lli_sa_lock); @@ -1481,7 +1484,12 @@ static int revalidate_statahead_dentry(struct inode *dir, } } - if (entry->se_state == SA_ENTRY_SUCC && entry->se_inode != NULL) { + /* + * We need to see the value that was set immediately before we + * were woken up. + */ + if (smp_load_acquire(&entry->se_state) == SA_ENTRY_SUCC && + entry->se_inode) { struct inode *inode = entry->se_inode; struct lookup_intent it = { .it_op = IT_GETATTR, .it_lock_handle =