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
|
|
@ -163,6 +163,7 @@ typedef struct __pnfs_layout {
|
||||||
enum pnfs_iomode iomode;
|
enum pnfs_iomode iomode;
|
||||||
enum pnfs_layout_status status;
|
enum pnfs_layout_status status;
|
||||||
bool_t return_on_close;
|
bool_t return_on_close;
|
||||||
|
LONG open_count; /* for return on last close */
|
||||||
uint32_t io_count; /* number of pending io operations */
|
uint32_t io_count; /* number of pending io operations */
|
||||||
SRWLOCK lock;
|
SRWLOCK lock;
|
||||||
} pnfs_layout;
|
} pnfs_layout;
|
||||||
|
|
|
||||||
|
|
@ -539,10 +539,11 @@ enum pnfs_status pnfs_open_state_layout(
|
||||||
if (status) {
|
if (status) {
|
||||||
status = file_layout_find_or_create(layouts, &state->file.fh, &layout);
|
status = file_layout_find_or_create(layouts, &state->file.fh, &layout);
|
||||||
if (status == PNFS_SUCCESS) {
|
if (status == PNFS_SUCCESS) {
|
||||||
|
LONG open_count = InterlockedIncrement(&layout->layout.open_count);
|
||||||
state->layout = layout;
|
state->layout = layout;
|
||||||
|
|
||||||
dprintf(FLLVL, "pnfs_open_state_layout() caching layout %p\n",
|
dprintf(FLLVL, "pnfs_open_state_layout() caching layout %p "
|
||||||
state->layout);
|
"(%u opens)\n", state->layout, open_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -576,7 +577,7 @@ void pnfs_open_state_close(
|
||||||
IN bool_t remove)
|
IN bool_t remove)
|
||||||
{
|
{
|
||||||
pnfs_file_layout *layout;
|
pnfs_file_layout *layout;
|
||||||
bool_t return_on_close;
|
bool_t return_layout;
|
||||||
enum pnfs_status status;
|
enum pnfs_status status;
|
||||||
|
|
||||||
AcquireSRWLockExclusive(&state->lock);
|
AcquireSRWLockExclusive(&state->lock);
|
||||||
|
|
@ -585,12 +586,14 @@ void pnfs_open_state_close(
|
||||||
ReleaseSRWLockExclusive(&state->lock);
|
ReleaseSRWLockExclusive(&state->lock);
|
||||||
|
|
||||||
if (layout) {
|
if (layout) {
|
||||||
/* check if we need to return the layout on close */
|
LONG open_count = InterlockedDecrement(&layout->layout.open_count);
|
||||||
|
|
||||||
AcquireSRWLockShared(&layout->layout.lock);
|
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);
|
ReleaseSRWLockShared(&layout->layout.lock);
|
||||||
|
|
||||||
if (return_on_close) {
|
if (return_layout) {
|
||||||
status = file_layout_return(session, &state->file, layout);
|
status = file_layout_return(session, &state->file, layout);
|
||||||
if (status)
|
if (status)
|
||||||
eprintf("file_layout_return() failed with %s\n",
|
eprintf("file_layout_return() failed with %s\n",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue