hw/9pfs: Implement TFLUSH operation
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
This commit is contained in:
		
							parent
							
								
									ce421a1961
								
							
						
					
					
						commit
						bccacf6c79
					
				| @ -17,11 +17,15 @@ | ||||
| #include "qemu-coroutine.h" | ||||
| #include "virtio-9p-coth.h" | ||||
| 
 | ||||
| int v9fs_co_readdir_r(V9fsState *s, V9fsFidState *fidp, struct dirent *dent, | ||||
| int v9fs_co_readdir_r(V9fsPDU *pdu, V9fsFidState *fidp, struct dirent *dent, | ||||
|                       struct dirent **result) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
|             errno = 0; | ||||
| @ -35,10 +39,14 @@ int v9fs_co_readdir_r(V9fsState *s, V9fsFidState *fidp, struct dirent *dent, | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| off_t v9fs_co_telldir(V9fsState *s, V9fsFidState *fidp) | ||||
| off_t v9fs_co_telldir(V9fsPDU *pdu, V9fsFidState *fidp) | ||||
| { | ||||
|     off_t err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
|             err = s->ops->telldir(&s->ctx, fidp->fs.dir); | ||||
| @ -49,29 +57,41 @@ off_t v9fs_co_telldir(V9fsState *s, V9fsFidState *fidp) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| void v9fs_co_seekdir(V9fsState *s, V9fsFidState *fidp, off_t offset) | ||||
| void v9fs_co_seekdir(V9fsPDU *pdu, V9fsFidState *fidp, off_t offset) | ||||
| { | ||||
|     V9fsState *s = pdu->s; | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return; | ||||
|     } | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
|             s->ops->seekdir(&s->ctx, fidp->fs.dir, offset); | ||||
|         }); | ||||
| } | ||||
| 
 | ||||
| void v9fs_co_rewinddir(V9fsState *s, V9fsFidState *fidp) | ||||
| void v9fs_co_rewinddir(V9fsPDU *pdu, V9fsFidState *fidp) | ||||
| { | ||||
|     V9fsState *s = pdu->s; | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return; | ||||
|     } | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
|             s->ops->rewinddir(&s->ctx, fidp->fs.dir); | ||||
|         }); | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_mkdir(V9fsState *s, V9fsFidState *fidp, V9fsString *name, | ||||
| int v9fs_co_mkdir(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name, | ||||
|                   mode_t mode, uid_t uid, gid_t gid, struct stat *stbuf) | ||||
| { | ||||
|     int err; | ||||
|     FsCred cred; | ||||
|     V9fsPath path; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR;; | ||||
|     } | ||||
|     cred_init(&cred); | ||||
|     cred.fc_mode = mode; | ||||
|     cred.fc_uid = uid; | ||||
| @ -98,10 +118,14 @@ int v9fs_co_mkdir(V9fsState *s, V9fsFidState *fidp, V9fsString *name, | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_opendir(V9fsState *s, V9fsFidState *fidp) | ||||
| int v9fs_co_opendir(V9fsPDU *pdu, V9fsFidState *fidp) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR;; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -116,16 +140,20 @@ int v9fs_co_opendir(V9fsState *s, V9fsFidState *fidp) | ||||
|     if (!err) { | ||||
|         total_open_fd++; | ||||
|         if (total_open_fd > open_fd_hw) { | ||||
|             v9fs_reclaim_fd(s); | ||||
|             v9fs_reclaim_fd(pdu); | ||||
|         } | ||||
|     } | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_closedir(V9fsState *s, DIR *dir) | ||||
| int v9fs_co_closedir(V9fsPDU *pdu, DIR *dir) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR;; | ||||
|     } | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
|             err = s->ops->closedir(&s->ctx, dir); | ||||
|  | ||||
| @ -17,10 +17,14 @@ | ||||
| #include "qemu-coroutine.h" | ||||
| #include "virtio-9p-coth.h" | ||||
| 
 | ||||
| int v9fs_co_lstat(V9fsState *s, V9fsPath *path, struct stat *stbuf) | ||||
| int v9fs_co_lstat(V9fsPDU *pdu, V9fsPath *path, struct stat *stbuf) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -33,10 +37,14 @@ int v9fs_co_lstat(V9fsState *s, V9fsPath *path, struct stat *stbuf) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_fstat(V9fsState *s, int fd, struct stat *stbuf) | ||||
| int v9fs_co_fstat(V9fsPDU *pdu, int fd, struct stat *stbuf) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
|             err = s->ops->fstat(&s->ctx, fd, stbuf); | ||||
| @ -47,10 +55,14 @@ int v9fs_co_fstat(V9fsState *s, int fd, struct stat *stbuf) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_open(V9fsState *s, V9fsFidState *fidp, int flags) | ||||
| int v9fs_co_open(V9fsPDU *pdu, V9fsFidState *fidp, int flags) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -65,20 +77,23 @@ int v9fs_co_open(V9fsState *s, V9fsFidState *fidp, int flags) | ||||
|     if (!err) { | ||||
|         total_open_fd++; | ||||
|         if (total_open_fd > open_fd_hw) { | ||||
|             v9fs_reclaim_fd(s); | ||||
|             v9fs_reclaim_fd(pdu); | ||||
|         } | ||||
|     } | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_open2(V9fsState *s, V9fsFidState *fidp, V9fsString *name, gid_t gid, | ||||
| int v9fs_co_open2(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name, gid_t gid, | ||||
|                   int flags, int mode, struct stat *stbuf) | ||||
| { | ||||
|     int err; | ||||
|     FsCred cred; | ||||
|     V9fsPath path; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     cred_init(&cred); | ||||
|     cred.fc_mode = mode & 07777; | ||||
|     cred.fc_uid = fidp->uid; | ||||
| @ -116,16 +131,20 @@ int v9fs_co_open2(V9fsState *s, V9fsFidState *fidp, V9fsString *name, gid_t gid, | ||||
|     if (!err) { | ||||
|         total_open_fd++; | ||||
|         if (total_open_fd > open_fd_hw) { | ||||
|             v9fs_reclaim_fd(s); | ||||
|             v9fs_reclaim_fd(pdu); | ||||
|         } | ||||
|     } | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_close(V9fsState *s, int fd) | ||||
| int v9fs_co_close(V9fsPDU *pdu, int fd) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
|             err = s->ops->close(&s->ctx, fd); | ||||
| @ -139,11 +158,14 @@ int v9fs_co_close(V9fsState *s, int fd) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_fsync(V9fsState *s, V9fsFidState *fidp, int datasync) | ||||
| int v9fs_co_fsync(V9fsPDU *pdu, V9fsFidState *fidp, int datasync) | ||||
| { | ||||
|     int fd; | ||||
|     int err; | ||||
|     int fd, err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     fd = fidp->fs.fd; | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -155,11 +177,15 @@ int v9fs_co_fsync(V9fsState *s, V9fsFidState *fidp, int datasync) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_link(V9fsState *s, V9fsFidState *oldfid, | ||||
| int v9fs_co_link(V9fsPDU *pdu, V9fsFidState *oldfid, | ||||
|                  V9fsFidState *newdirfid, V9fsString *name) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -173,12 +199,15 @@ int v9fs_co_link(V9fsState *s, V9fsFidState *oldfid, | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_pwritev(V9fsState *s, V9fsFidState *fidp, | ||||
| int v9fs_co_pwritev(V9fsPDU *pdu, V9fsFidState *fidp, | ||||
|                     struct iovec *iov, int iovcnt, int64_t offset) | ||||
| { | ||||
|     int fd; | ||||
|     int err; | ||||
|     int fd, err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     fd = fidp->fs.fd; | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -190,12 +219,15 @@ int v9fs_co_pwritev(V9fsState *s, V9fsFidState *fidp, | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_preadv(V9fsState *s, V9fsFidState *fidp, | ||||
| int v9fs_co_preadv(V9fsPDU *pdu, V9fsFidState *fidp, | ||||
|                    struct iovec *iov, int iovcnt, int64_t offset) | ||||
| { | ||||
|     int fd; | ||||
|     int err; | ||||
|     int fd, err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     fd = fidp->fs.fd; | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
|  | ||||
| @ -17,11 +17,15 @@ | ||||
| #include "qemu-coroutine.h" | ||||
| #include "virtio-9p-coth.h" | ||||
| 
 | ||||
| int v9fs_co_readlink(V9fsState *s, V9fsPath *path, V9fsString *buf) | ||||
| int v9fs_co_readlink(V9fsPDU *pdu, V9fsPath *path, V9fsString *buf) | ||||
| { | ||||
|     int err; | ||||
|     ssize_t len; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     buf->data = g_malloc(PATH_MAX); | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
| @ -45,10 +49,14 @@ int v9fs_co_readlink(V9fsState *s, V9fsPath *path, V9fsString *buf) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_statfs(V9fsState *s, V9fsPath *path, struct statfs *stbuf) | ||||
| int v9fs_co_statfs(V9fsPDU *pdu, V9fsPath *path, struct statfs *stbuf) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -61,11 +69,15 @@ int v9fs_co_statfs(V9fsState *s, V9fsPath *path, struct statfs *stbuf) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_chmod(V9fsState *s, V9fsPath *path, mode_t mode) | ||||
| int v9fs_co_chmod(V9fsPDU *pdu, V9fsPath *path, mode_t mode) | ||||
| { | ||||
|     int err; | ||||
|     FsCred cred; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     cred_init(&cred); | ||||
|     cred.fc_mode = mode; | ||||
|     v9fs_path_read_lock(s); | ||||
| @ -80,11 +92,15 @@ int v9fs_co_chmod(V9fsState *s, V9fsPath *path, mode_t mode) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_utimensat(V9fsState *s, V9fsPath *path, | ||||
| int v9fs_co_utimensat(V9fsPDU *pdu, V9fsPath *path, | ||||
|                       struct timespec times[2]) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -97,11 +113,15 @@ int v9fs_co_utimensat(V9fsState *s, V9fsPath *path, | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_chown(V9fsState *s, V9fsPath *path, uid_t uid, gid_t gid) | ||||
| int v9fs_co_chown(V9fsPDU *pdu, V9fsPath *path, uid_t uid, gid_t gid) | ||||
| { | ||||
|     int err; | ||||
|     FsCred cred; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     cred_init(&cred); | ||||
|     cred.fc_uid = uid; | ||||
|     cred.fc_gid = gid; | ||||
| @ -117,10 +137,14 @@ int v9fs_co_chown(V9fsState *s, V9fsPath *path, uid_t uid, gid_t gid) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_truncate(V9fsState *s, V9fsPath *path, off_t size) | ||||
| int v9fs_co_truncate(V9fsPDU *pdu, V9fsPath *path, off_t size) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -133,13 +157,17 @@ int v9fs_co_truncate(V9fsState *s, V9fsPath *path, off_t size) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_mknod(V9fsState *s, V9fsFidState *fidp, V9fsString *name, uid_t uid, | ||||
| int v9fs_co_mknod(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name, uid_t uid, | ||||
|                   gid_t gid, dev_t dev, mode_t mode, struct stat *stbuf) | ||||
| { | ||||
|     int err; | ||||
|     V9fsPath path; | ||||
|     FsCred cred; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     cred_init(&cred); | ||||
|     cred.fc_uid  = uid; | ||||
|     cred.fc_gid  = gid; | ||||
| @ -168,10 +196,14 @@ int v9fs_co_mknod(V9fsState *s, V9fsFidState *fidp, V9fsString *name, uid_t uid, | ||||
| } | ||||
| 
 | ||||
| /* Only works with path name based fid */ | ||||
| int v9fs_co_remove(V9fsState *s, V9fsPath *path) | ||||
| int v9fs_co_remove(V9fsPDU *pdu, V9fsPath *path) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -184,10 +216,14 @@ int v9fs_co_remove(V9fsState *s, V9fsPath *path) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_unlinkat(V9fsState *s, V9fsPath *path, V9fsString *name, int flags) | ||||
| int v9fs_co_unlinkat(V9fsPDU *pdu, V9fsPath *path, V9fsString *name, int flags) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -201,10 +237,14 @@ int v9fs_co_unlinkat(V9fsState *s, V9fsPath *path, V9fsString *name, int flags) | ||||
| } | ||||
| 
 | ||||
| /* Only work with path name based fid */ | ||||
| int v9fs_co_rename(V9fsState *s, V9fsPath *oldpath, V9fsPath *newpath) | ||||
| int v9fs_co_rename(V9fsPDU *pdu, V9fsPath *oldpath, V9fsPath *newpath) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
|             err = s->ops->rename(&s->ctx, oldpath->data, newpath->data); | ||||
| @ -215,11 +255,15 @@ int v9fs_co_rename(V9fsState *s, V9fsPath *oldpath, V9fsPath *newpath) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_renameat(V9fsState *s, V9fsPath *olddirpath, V9fsString *oldname, | ||||
| int v9fs_co_renameat(V9fsPDU *pdu, V9fsPath *olddirpath, V9fsString *oldname, | ||||
|                      V9fsPath *newdirpath, V9fsString *newname) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
|             err = s->ops->renameat(&s->ctx, olddirpath, oldname->data, | ||||
| @ -231,14 +275,17 @@ int v9fs_co_renameat(V9fsState *s, V9fsPath *olddirpath, V9fsString *oldname, | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_symlink(V9fsState *s, V9fsFidState *dfidp, V9fsString *name, | ||||
| int v9fs_co_symlink(V9fsPDU *pdu, V9fsFidState *dfidp, V9fsString *name, | ||||
|                     const char *oldpath, gid_t gid, struct stat *stbuf) | ||||
| { | ||||
|     int err; | ||||
|     FsCred cred; | ||||
|     V9fsPath path; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     cred_init(&cred); | ||||
|     cred.fc_uid = dfidp->uid; | ||||
|     cred.fc_gid = gid; | ||||
| @ -270,10 +317,11 @@ int v9fs_co_symlink(V9fsState *s, V9fsFidState *dfidp, V9fsString *name, | ||||
|  * For path name based fid we don't block. So we can | ||||
|  * directly call the fs driver ops. | ||||
|  */ | ||||
| int v9fs_co_name_to_path(V9fsState *s, V9fsPath *dirpath, | ||||
| int v9fs_co_name_to_path(V9fsPDU *pdu, V9fsPath *dirpath, | ||||
|                          const char *name, V9fsPath *path) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (s->ctx.flags & PATHNAME_FSCONTEXT) { | ||||
|         err = s->ops->name_to_path(&s->ctx, dirpath, name, path); | ||||
| @ -281,6 +329,9 @@ int v9fs_co_name_to_path(V9fsState *s, V9fsPath *dirpath, | ||||
|             err = -errno; | ||||
|         } | ||||
|     } else { | ||||
|         if (v9fs_request_cancelled(pdu)) { | ||||
|             return -EINTR; | ||||
|         } | ||||
|         v9fs_co_run_in_worker( | ||||
|             { | ||||
|                 err = s->ops->name_to_path(&s->ctx, dirpath, name, path); | ||||
|  | ||||
| @ -17,10 +17,14 @@ | ||||
| #include "qemu-coroutine.h" | ||||
| #include "virtio-9p-coth.h" | ||||
| 
 | ||||
| int v9fs_co_llistxattr(V9fsState *s, V9fsPath *path, void *value, size_t size) | ||||
| int v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value, size_t size) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -33,12 +37,16 @@ int v9fs_co_llistxattr(V9fsState *s, V9fsPath *path, void *value, size_t size) | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_lgetxattr(V9fsState *s, V9fsPath *path, | ||||
| int v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path, | ||||
|                       V9fsString *xattr_name, | ||||
|                       void *value, size_t size) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -53,12 +61,16 @@ int v9fs_co_lgetxattr(V9fsState *s, V9fsPath *path, | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_lsetxattr(V9fsState *s, V9fsPath *path, | ||||
| int v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path, | ||||
|                       V9fsString *xattr_name, void *value, | ||||
|                       size_t size, int flags) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
| @ -73,11 +85,15 @@ int v9fs_co_lsetxattr(V9fsState *s, V9fsPath *path, | ||||
|     return err; | ||||
| } | ||||
| 
 | ||||
| int v9fs_co_lremovexattr(V9fsState *s, V9fsPath *path, | ||||
| int v9fs_co_lremovexattr(V9fsPDU *pdu, V9fsPath *path, | ||||
|                          V9fsString *xattr_name) | ||||
| { | ||||
|     int err; | ||||
|     V9fsState *s = pdu->s; | ||||
| 
 | ||||
|     if (v9fs_request_cancelled(pdu)) { | ||||
|         return -EINTR; | ||||
|     } | ||||
|     v9fs_path_read_lock(s); | ||||
|     v9fs_co_run_in_worker( | ||||
|         { | ||||
|  | ||||
| @ -56,49 +56,49 @@ typedef struct V9fsThPool { | ||||
| 
 | ||||
| extern void co_run_in_worker_bh(void *); | ||||
| extern int v9fs_init_worker_threads(void); | ||||
| extern int v9fs_co_readlink(V9fsState *, V9fsPath *, V9fsString *); | ||||
| extern int v9fs_co_readdir_r(V9fsState *, V9fsFidState *, | ||||
| extern int v9fs_co_readlink(V9fsPDU *, V9fsPath *, V9fsString *); | ||||
| extern int v9fs_co_readdir_r(V9fsPDU *, V9fsFidState *, | ||||
|                            struct dirent *, struct dirent **result); | ||||
| extern off_t v9fs_co_telldir(V9fsState *, V9fsFidState *); | ||||
| extern void v9fs_co_seekdir(V9fsState *, V9fsFidState *, off_t); | ||||
| extern void v9fs_co_rewinddir(V9fsState *, V9fsFidState *); | ||||
| extern int v9fs_co_statfs(V9fsState *, V9fsPath *, struct statfs *); | ||||
| extern int v9fs_co_lstat(V9fsState *, V9fsPath *, struct stat *); | ||||
| extern int v9fs_co_chmod(V9fsState *, V9fsPath *, mode_t); | ||||
| extern int v9fs_co_utimensat(V9fsState *, V9fsPath *, struct timespec [2]); | ||||
| extern int v9fs_co_chown(V9fsState *, V9fsPath *, uid_t, gid_t); | ||||
| extern int v9fs_co_truncate(V9fsState *, V9fsPath *, off_t); | ||||
| extern int v9fs_co_llistxattr(V9fsState *, V9fsPath *, void *, size_t); | ||||
| extern int v9fs_co_lgetxattr(V9fsState *, V9fsPath *, | ||||
| extern off_t v9fs_co_telldir(V9fsPDU *, V9fsFidState *); | ||||
| extern void v9fs_co_seekdir(V9fsPDU *, V9fsFidState *, off_t); | ||||
| extern void v9fs_co_rewinddir(V9fsPDU *, V9fsFidState *); | ||||
| extern int v9fs_co_statfs(V9fsPDU *, V9fsPath *, struct statfs *); | ||||
| extern int v9fs_co_lstat(V9fsPDU *, V9fsPath *, struct stat *); | ||||
| extern int v9fs_co_chmod(V9fsPDU *, V9fsPath *, mode_t); | ||||
| extern int v9fs_co_utimensat(V9fsPDU *, V9fsPath *, struct timespec [2]); | ||||
| extern int v9fs_co_chown(V9fsPDU *, V9fsPath *, uid_t, gid_t); | ||||
| extern int v9fs_co_truncate(V9fsPDU *, V9fsPath *, off_t); | ||||
| extern int v9fs_co_llistxattr(V9fsPDU *, V9fsPath *, void *, size_t); | ||||
| extern int v9fs_co_lgetxattr(V9fsPDU *, V9fsPath *, | ||||
|                              V9fsString *, void *, size_t); | ||||
| extern int v9fs_co_mknod(V9fsState *, V9fsFidState *, V9fsString *, uid_t, | ||||
| extern int v9fs_co_mknod(V9fsPDU *, V9fsFidState *, V9fsString *, uid_t, | ||||
|                          gid_t, dev_t, mode_t, struct stat *); | ||||
| extern int v9fs_co_mkdir(V9fsState *, V9fsFidState *, V9fsString *, | ||||
| extern int v9fs_co_mkdir(V9fsPDU *, V9fsFidState *, V9fsString *, | ||||
|                          mode_t, uid_t, gid_t, struct stat *); | ||||
| extern int v9fs_co_remove(V9fsState *, V9fsPath *); | ||||
| extern int v9fs_co_rename(V9fsState *, V9fsPath *, V9fsPath *); | ||||
| extern int v9fs_co_unlinkat(V9fsState *, V9fsPath *, V9fsString *, int flags); | ||||
| extern int v9fs_co_renameat(V9fsState *, V9fsPath *, V9fsString *, | ||||
| extern int v9fs_co_remove(V9fsPDU *, V9fsPath *); | ||||
| extern int v9fs_co_rename(V9fsPDU *, V9fsPath *, V9fsPath *); | ||||
| extern int v9fs_co_unlinkat(V9fsPDU *, V9fsPath *, V9fsString *, int flags); | ||||
| extern int v9fs_co_renameat(V9fsPDU *, V9fsPath *, V9fsString *, | ||||
|                             V9fsPath *, V9fsString *); | ||||
| extern int v9fs_co_fstat(V9fsState *, int, struct stat *); | ||||
| extern int v9fs_co_opendir(V9fsState *, V9fsFidState *); | ||||
| extern int v9fs_co_open(V9fsState *, V9fsFidState *, int); | ||||
| extern int v9fs_co_open2(V9fsState *, V9fsFidState *, V9fsString *, | ||||
| extern int v9fs_co_fstat(V9fsPDU *, int, struct stat *); | ||||
| extern int v9fs_co_opendir(V9fsPDU *, V9fsFidState *); | ||||
| extern int v9fs_co_open(V9fsPDU *, V9fsFidState *, int); | ||||
| extern int v9fs_co_open2(V9fsPDU *, V9fsFidState *, V9fsString *, | ||||
|                          gid_t, int, int, struct stat *); | ||||
| extern int v9fs_co_lsetxattr(V9fsState *, V9fsPath *, V9fsString *, | ||||
| extern int v9fs_co_lsetxattr(V9fsPDU *, V9fsPath *, V9fsString *, | ||||
|                              void *, size_t, int); | ||||
| extern int v9fs_co_lremovexattr(V9fsState *, V9fsPath *, V9fsString *); | ||||
| extern int v9fs_co_closedir(V9fsState *, DIR *); | ||||
| extern int v9fs_co_close(V9fsState *, int); | ||||
| extern int v9fs_co_fsync(V9fsState *, V9fsFidState *, int); | ||||
| extern int v9fs_co_symlink(V9fsState *, V9fsFidState *, V9fsString *, | ||||
| extern int v9fs_co_lremovexattr(V9fsPDU *, V9fsPath *, V9fsString *); | ||||
| extern int v9fs_co_closedir(V9fsPDU *, DIR *); | ||||
| extern int v9fs_co_close(V9fsPDU *, int); | ||||
| extern int v9fs_co_fsync(V9fsPDU *, V9fsFidState *, int); | ||||
| extern int v9fs_co_symlink(V9fsPDU *, V9fsFidState *, V9fsString *, | ||||
|                            const char *, gid_t, struct stat *); | ||||
| extern int v9fs_co_link(V9fsState *, V9fsFidState *, | ||||
| extern int v9fs_co_link(V9fsPDU *, V9fsFidState *, | ||||
|                         V9fsFidState *, V9fsString *); | ||||
| extern int v9fs_co_pwritev(V9fsState *, V9fsFidState *, | ||||
| extern int v9fs_co_pwritev(V9fsPDU *, V9fsFidState *, | ||||
|                            struct iovec *, int, int64_t); | ||||
| extern int v9fs_co_preadv(V9fsState *, V9fsFidState *, | ||||
| extern int v9fs_co_preadv(V9fsPDU *, V9fsFidState *, | ||||
|                           struct iovec *, int, int64_t); | ||||
| extern int v9fs_co_name_to_path(V9fsState *, V9fsPath *, | ||||
| extern int v9fs_co_name_to_path(V9fsPDU *, V9fsPath *, | ||||
|                                 const char *, V9fsPath *); | ||||
| #endif | ||||
|  | ||||
| @ -58,6 +58,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) | ||||
|                                     sizeof(V9fsState)); | ||||
|     /* initialize pdu allocator */ | ||||
|     QLIST_INIT(&s->free_list); | ||||
|     QLIST_INIT(&s->active_list); | ||||
|     for (i = 0; i < (MAX_REQ - 1); i++) { | ||||
|         QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next); | ||||
|     } | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -131,6 +131,8 @@ struct V9fsPDU | ||||
|     uint32_t size; | ||||
|     uint16_t tag; | ||||
|     uint8_t id; | ||||
|     uint8_t cancelled; | ||||
|     CoQueue complete; | ||||
|     VirtQueueElement elem; | ||||
|     struct V9fsState *s; | ||||
|     QLIST_ENTRY(V9fsPDU) next; | ||||
| @ -231,6 +233,7 @@ typedef struct V9fsState | ||||
|     VirtQueue *vq; | ||||
|     V9fsPDU pdus[MAX_REQ]; | ||||
|     QLIST_HEAD(, V9fsPDU) free_list; | ||||
|     QLIST_HEAD(, V9fsPDU) active_list; | ||||
|     V9fsFidState *fid_list; | ||||
|     FileOperations *ops; | ||||
|     FsContext ctx; | ||||
| @ -409,9 +412,14 @@ static inline void v9fs_path_unlock(V9fsState *s) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| static inline uint8_t v9fs_request_cancelled(V9fsPDU *pdu) | ||||
| { | ||||
|     return pdu->cancelled; | ||||
| } | ||||
| 
 | ||||
| extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq); | ||||
| extern void virtio_9p_set_fd_limit(void); | ||||
| extern void v9fs_reclaim_fd(V9fsState *s); | ||||
| extern void v9fs_reclaim_fd(V9fsPDU *pdu); | ||||
| extern void v9fs_string_init(V9fsString *str); | ||||
| extern void v9fs_string_free(V9fsString *str); | ||||
| extern void v9fs_string_null(V9fsString *str); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Aneesh Kumar K.V
						Aneesh Kumar K.V