pnfs: only return-on-close for last close
added pnfs_layout.open_count to count open references, and only return the layout when pnfs_open_state_close() takes the open_count to 0 use InterlockedIncrement/Decrement to avoid an exclusive lock on the layout Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
parent
83ab0b3f86
commit
d7e438be5e
2 changed files with 10 additions and 6 deletions
|
|
@ -539,10 +539,11 @@ enum pnfs_status pnfs_open_state_layout(
|
|||
if (status) {
|
||||
status = file_layout_find_or_create(layouts, &state->file.fh, &layout);
|
||||
if (status == PNFS_SUCCESS) {
|
||||
LONG open_count = InterlockedIncrement(&layout->layout.open_count);
|
||||
state->layout = layout;
|
||||
|
||||
dprintf(FLLVL, "pnfs_open_state_layout() caching layout %p\n",
|
||||
state->layout);
|
||||
dprintf(FLLVL, "pnfs_open_state_layout() caching layout %p "
|
||||
"(%u opens)\n", state->layout, open_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -576,7 +577,7 @@ void pnfs_open_state_close(
|
|||
IN bool_t remove)
|
||||
{
|
||||
pnfs_file_layout *layout;
|
||||
bool_t return_on_close;
|
||||
bool_t return_layout;
|
||||
enum pnfs_status status;
|
||||
|
||||
AcquireSRWLockExclusive(&state->lock);
|
||||
|
|
@ -585,12 +586,14 @@ void pnfs_open_state_close(
|
|||
ReleaseSRWLockExclusive(&state->lock);
|
||||
|
||||
if (layout) {
|
||||
/* check if we need to return the layout on close */
|
||||
LONG open_count = InterlockedDecrement(&layout->layout.open_count);
|
||||
|
||||
AcquireSRWLockShared(&layout->layout.lock);
|
||||
return_on_close = layout->layout.return_on_close;
|
||||
/* only return on close if it's the last close */
|
||||
return_layout = layout->layout.return_on_close && (open_count <= 0);
|
||||
ReleaseSRWLockShared(&layout->layout.lock);
|
||||
|
||||
if (return_on_close) {
|
||||
if (return_layout) {
|
||||
status = file_layout_return(session, &state->file, layout);
|
||||
if (status)
|
||||
eprintf("file_layout_return() failed with %s\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue