mirror of
https://github.com/qemu/qemu.git
synced 2025-08-08 08:05:17 +00:00
hw/9pfs: mark directories also as un-reclaimable on unlink
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
This commit is contained in:
parent
95f65511c3
commit
b9cb88b056
@ -235,6 +235,27 @@ static size_t v9fs_string_size(V9fsString *str)
|
|||||||
return str->size;
|
return str->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns 0 if fid got re-opened, 1 if not, < 0 on error */
|
||||||
|
static int v9fs_reopen_fid(V9fsState *s, V9fsFidState *f)
|
||||||
|
{
|
||||||
|
int err = 1;
|
||||||
|
if (f->fid_type == P9_FID_FILE) {
|
||||||
|
if (f->fs.fd == -1) {
|
||||||
|
do {
|
||||||
|
err = v9fs_co_open(s, f, f->open_flags);
|
||||||
|
} while (err == -EINTR);
|
||||||
|
}
|
||||||
|
} else if (f->fid_type == P9_FID_DIR) {
|
||||||
|
if (f->fs.dir == NULL) {
|
||||||
|
do {
|
||||||
|
err = v9fs_co_opendir(s, f);
|
||||||
|
} while (err == -EINTR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
static V9fsFidState *get_fid(V9fsState *s, int32_t fid)
|
static V9fsFidState *get_fid(V9fsState *s, int32_t fid)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
@ -249,34 +270,17 @@ static V9fsFidState *get_fid(V9fsState *s, int32_t fid)
|
|||||||
* in open later.
|
* in open later.
|
||||||
*/
|
*/
|
||||||
f->ref++;
|
f->ref++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check whether we need to reopen the
|
* check whether we need to reopen the
|
||||||
* file. We might have closed the fd
|
* file. We might have closed the fd
|
||||||
* while trying to free up some file
|
* while trying to free up some file
|
||||||
* descriptors.
|
* descriptors.
|
||||||
*/
|
*/
|
||||||
if (f->fid_type == P9_FID_FILE) {
|
err = v9fs_reopen_fid(s, f);
|
||||||
if (f->fs.fd == -1) {
|
if (err < 0) {
|
||||||
do {
|
f->ref--;
|
||||||
err = v9fs_co_open(s, f, f->open_flags);
|
return NULL;
|
||||||
} while (err == -EINTR);
|
}
|
||||||
if (err < 0) {
|
|
||||||
f->ref--;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (f->fid_type == P9_FID_DIR) {
|
|
||||||
if (f->fs.dir == NULL) {
|
|
||||||
do {
|
|
||||||
err = v9fs_co_opendir(s, f);
|
|
||||||
} while (err == -EINTR);
|
|
||||||
if (err < 0) {
|
|
||||||
f->ref--;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Mark the fid as referenced so that the LRU
|
* Mark the fid as referenced so that the LRU
|
||||||
* reclaim won't close the file descriptor
|
* reclaim won't close the file descriptor
|
||||||
@ -490,19 +494,18 @@ static int v9fs_mark_fids_unreclaim(V9fsState *s, V9fsString *str)
|
|||||||
if (!strcmp(fidp->path.data, str->data)) {
|
if (!strcmp(fidp->path.data, str->data)) {
|
||||||
/* Mark the fid non reclaimable. */
|
/* Mark the fid non reclaimable. */
|
||||||
fidp->flags |= FID_NON_RECLAIMABLE;
|
fidp->flags |= FID_NON_RECLAIMABLE;
|
||||||
/* reopen the file if already closed */
|
|
||||||
if (fidp->fs.fd == -1) {
|
/* reopen the file/dir if already closed */
|
||||||
do {
|
err = v9fs_reopen_fid(s, fidp);
|
||||||
err = v9fs_co_open(s, fidp, fidp->open_flags);
|
if (err < 0) {
|
||||||
} while (err == -EINTR);
|
return -1;
|
||||||
if (err < 0) {
|
}
|
||||||
return -1;
|
/*
|
||||||
}
|
* Go back to head of fid list because
|
||||||
/*
|
* the list could have got updated when
|
||||||
* Go back to head of fid list because
|
* switched to the worker thread
|
||||||
* the list could have got updated when
|
*/
|
||||||
* switched to the worker thread
|
if (err == 0) {
|
||||||
*/
|
|
||||||
fidp = &head_fid;
|
fidp = &head_fid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user