From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 6/6] hw/9pfs: mark directories also as un-reclaimable on unlink
Date: Thu, 25 Aug 2011 20:33:44 +0530 [thread overview]
Message-ID: <1314284624-14821-7-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1314284624-14821-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
hw/9pfs/virtio-9p.c | 73 ++++++++++++++++++++++++++------------------------
1 files changed, 38 insertions(+), 35 deletions(-)
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 16f7d4e..94b7090 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -235,6 +235,27 @@ static size_t v9fs_string_size(V9fsString *str)
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)
{
int err;
@@ -249,34 +270,17 @@ static V9fsFidState *get_fid(V9fsState *s, int32_t fid)
* in open later.
*/
f->ref++;
-
/*
* check whether we need to reopen the
* file. We might have closed the fd
* while trying to free up some file
* descriptors.
*/
- 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);
- 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;
- }
- }
- }
+ err = v9fs_reopen_fid(s, f);
+ if (err < 0) {
+ f->ref--;
+ return NULL;
+ }
/*
* Mark the fid as referenced so that the LRU
* 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)) {
/* Mark the fid non reclaimable. */
fidp->flags |= FID_NON_RECLAIMABLE;
- /* reopen the file if already closed */
- if (fidp->fs.fd == -1) {
- do {
- err = v9fs_co_open(s, fidp, fidp->open_flags);
- } while (err == -EINTR);
- if (err < 0) {
- return -1;
- }
- /*
- * Go back to head of fid list because
- * the list could have got updated when
- * switched to the worker thread
- */
+
+ /* reopen the file/dir if already closed */
+ err = v9fs_reopen_fid(s, fidp);
+ if (err < 0) {
+ return -1;
+ }
+ /*
+ * Go back to head of fid list because
+ * the list could have got updated when
+ * switched to the worker thread
+ */
+ if (err == 0) {
fidp = &head_fid;
}
}
--
1.7.4.1
prev parent reply other threads:[~2011-08-25 15:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-25 15:03 [Qemu-devel] [PATCH 0/6] hw/9pfs: Implement file descriptor reclaim in VirtFS server Aneesh Kumar K.V
2011-08-25 15:03 ` [Qemu-devel] [PATCH 1/6] hw/9pfs: Add reference counting for fid Aneesh Kumar K.V
2011-08-25 15:03 ` [Qemu-devel] [PATCH 2/6] hw/9pfs: Add file descriptor reclaim support Aneesh Kumar K.V
2011-08-25 15:03 ` [Qemu-devel] [PATCH 3/6] hw/9pfs: init fid list properly Aneesh Kumar K.V
2011-08-25 15:03 ` [Qemu-devel] [PATCH 4/6] hw/9pfs: Use v9fs_do_close instead of close Aneesh Kumar K.V
2011-08-25 15:03 ` [Qemu-devel] [PATCH 5/6] hw/9pfs: Add directory reclaim support Aneesh Kumar K.V
2011-08-25 15:03 ` Aneesh Kumar K.V [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1314284624-14821-7-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).