/** * @brief Commit a byte range to a DS handle. * * NFSv4.1 data server filehandles are disjount from normal * filehandles (in Ganesha, there is a ds_flag in the filehandle_v4_t * structure) and do not get loaded into cache_inode or processed the * normal way. * * @param[in] ds_pub FSAL DS handle * @param[in] req_ctx Credentials * @param[in] offset Start of commit window * @param[in] count Length of commit window * @param[out] writeverf Write verifier * * @return An NFSv4.1 status code. */ static nfsstat4 ds_commit(struct fsal_ds_handle *const ds_pub, struct req_op_context *const req_ctx, const offset4 offset, const count4 count, verifier4 * const writeverf) { memset(writeverf, 0, NFS4_VERIFIER_SIZE); struct glfs_ds_handle *ds = container_of(ds_pub, struct glfs_ds_handle, ds); int rc = 0; fsal_status_t status = { ERR_FSAL_NO_ERROR, 0 }; if (ds->stability_got == FILE_SYNC4) { struct glusterfs_export *glfs_export = container_of(ds_pub->pds->mds_fsal_export, struct glusterfs_export, export); struct glfs_fd *glfd = NULL; SET_GLUSTER_CREDS(glfs_export, &op_ctx->creds->caller_uid, &op_ctx->creds->caller_gid, op_ctx->creds->caller_glen, op_ctx->creds->caller_garray); glfd = glfs_h_open(glfs_export->gl_fs->fs, ds->glhandle, O_RDWR); if (glfd == NULL) { LogDebug(COMPONENT_PNFS, "glfd in ds_handle is NULL"); SET_GLUSTER_CREDS(glfs_export, NULL, NULL, 0, NULL); return NFS4ERR_SERVERFAULT; } rc = glfs_fsync(glfd); if (rc != 0) LogMajor(COMPONENT_PNFS, "ds_commit() failed %d", -rc); rc = glfs_close(glfd); if (rc != 0) LogDebug(COMPONENT_PNFS, "status after close %d", -rc); SET_GLUSTER_CREDS(glfs_export, NULL, NULL, 0, NULL); } if ((rc != 0) || (status.major != ERR_FSAL_NO_ERROR)) return NFS4ERR_INVAL; return NFS4_OK; }
static int fio_gf_queue(struct thread_data *td, struct io_u *io_u) { struct gf_data *g = td->io_ops_data; int ret = 0; dprint(FD_FILE, "fio queue len %lu\n", io_u->xfer_buflen); fio_ro_check(td, io_u); if (io_u->ddir == DDIR_READ) ret = glfs_read(g->fd, io_u->xfer_buf, io_u->xfer_buflen, 0); else if (io_u->ddir == DDIR_WRITE) ret = glfs_write(g->fd, io_u->xfer_buf, io_u->xfer_buflen, 0); else if (io_u->ddir == DDIR_SYNC) ret = glfs_fsync(g->fd); else if (io_u->ddir == DDIR_DATASYNC) ret = glfs_fdatasync(g->fd); else { log_err("unsupported operation.\n"); return -EINVAL; } dprint(FD_FILE, "fio len %lu ret %d\n", io_u->xfer_buflen, ret); if (io_u->file && ret >= 0 && ddir_rw(io_u->ddir)) LAST_POS(io_u->file) = io_u->offset + ret; if (ret != (int)io_u->xfer_buflen) { if (ret >= 0) { io_u->resid = io_u->xfer_buflen - ret; io_u->error = 0; return FIO_Q_COMPLETED; } else io_u->error = errno; } if (io_u->error) { log_err("IO failed.\n"); td_verror(td, io_u->error, "xfer"); } return FIO_Q_COMPLETED; }
static fsal_status_t commit(struct fsal_obj_handle *obj_hdl, /* sync */ off_t offset, size_t len) { int rc = 0; fsal_status_t status = { ERR_FSAL_NO_ERROR, 0 }; struct glusterfs_handle *objhandle = container_of(obj_hdl, struct glusterfs_handle, handle); #ifdef GLTIMING struct timespec s_time, e_time; now(&s_time); #endif /* TODO: Everybody pretty much ignores the range sent */ rc = glfs_fsync(objhandle->glfd); if (rc < 0) { status = gluster2fsal_error(errno); } #ifdef GLTIMING now(&e_time); latency_update(&s_time, &e_time, lat_commit); #endif return status; }