int nfs3_Pathconf(nfs_arg_t * parg, exportlist_t * pexport, fsal_op_context_t * pcontext, cache_inode_client_t * pclient, hash_table_t * ht, struct svc_req *preq, nfs_res_t * pres) { static char __attribute__ ((__unused__)) funcName[] = "nfs3_Pathconf"; cache_inode_status_t cache_status; cache_entry_t *pentry = NULL; cache_inode_fsal_data_t fsal_data; fsal_attrib_list_t attr; fsal_staticfsinfo_t staticinfo; fsal_dynamicfsinfo_t dynamicinfo; /* to avoid setting it on each error case */ pres->res_pathconf3.PATHCONF3res_u.resfail.obj_attributes.attributes_follow = FALSE; /* Convert file handle into a fsal_handle */ if(nfs3_FhandleToFSAL(&(parg->arg_access3.object), &fsal_data.handle, pcontext) == 0) return NFS_REQ_DROP; /* Set cookie to zero */ fsal_data.cookie = DIR_START; /* Get the entry in the cache_inode */ if((pentry = cache_inode_get(&fsal_data, &attr, ht, pclient, pcontext, &cache_status)) == NULL) { /* Stale NFS FH ? */ pres->res_pathconf3.status = NFS3ERR_STALE; return NFS_REQ_OK; } /* Get the filesystem information */ if(cache_inode_statfs(pentry, &staticinfo, &dynamicinfo, pcontext, &cache_status) != CACHE_INODE_SUCCESS) { pres->res_pathconf3.status = nfs3_Errno(cache_status); return NFS_REQ_OK; } /* Build post op file attributes */ nfs_SetPostOpAttr(pcontext, pexport, pentry, &attr, &(pres->res_pathconf3.PATHCONF3res_u.resok.obj_attributes)); pres->res_pathconf3.PATHCONF3res_u.resok.linkmax = staticinfo.maxlink; pres->res_pathconf3.PATHCONF3res_u.resok.name_max = staticinfo.maxnamelen; pres->res_pathconf3.PATHCONF3res_u.resok.no_trunc = staticinfo.no_trunc; pres->res_pathconf3.PATHCONF3res_u.resok.chown_restricted = staticinfo.chown_restricted; pres->res_pathconf3.PATHCONF3res_u.resok.case_insensitive = staticinfo.case_insensitive; pres->res_pathconf3.PATHCONF3res_u.resok.case_preserving = staticinfo.case_preserving; return NFS_REQ_OK; } /* nfs3_Pathconf */
int nfs_Fsstat(nfs_arg_t *parg, exportlist_t *pexport, fsal_op_context_t *pcontext, nfs_worker_data_t *pworker, struct svc_req *preq, nfs_res_t * pres) { fsal_dynamicfsinfo_t dynamicinfo; cache_inode_status_t cache_status; cache_entry_t *pentry = NULL; fsal_attrib_list_t attr; int rc = NFS_REQ_OK; if(isDebug(COMPONENT_NFSPROTO)) { char str[LEN_FH_STR]; nfs_FhandleToStr(preq->rq_vers, &(parg->arg_statfs2), &(parg->arg_fsstat3.fsroot), NULL, str); LogDebug(COMPONENT_NFSPROTO, "REQUEST PROCESSING: Calling nfs_Fsstat handle: %s", str); } if(preq->rq_vers == NFS_V3) { /* to avoid setting it on each error case */ pres->res_fsstat3.FSSTAT3res_u.resfail.obj_attributes.attributes_follow = FALSE; } /* convert file handle to vnode */ if((pentry = nfs_FhandleToCache(preq->rq_vers, &(parg->arg_statfs2), &(parg->arg_fsstat3.fsroot), NULL, &(pres->res_statfs2.status), &(pres->res_fsstat3.status), NULL, NULL, pcontext, &rc)) == NULL) { /* Stale NFS FH ? */ /* return NFS_REQ_DROP ; */ goto out; } /* Get statistics and convert from cache */ if((cache_status = cache_inode_statfs(pentry, &dynamicinfo, pcontext, &cache_status)) == CACHE_INODE_SUCCESS) { /* This call is costless, the pentry was cached during call to nfs_FhandleToCache */ if((cache_status = cache_inode_getattr(pentry, &attr, pcontext, &cache_status)) == CACHE_INODE_SUCCESS) { LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> dynamicinfo.total_bytes = %zu dynamicinfo.free_bytes = %zu dynamicinfo.avail_bytes = %zu", dynamicinfo.total_bytes, dynamicinfo.free_bytes, dynamicinfo.avail_bytes); LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> dynamicinfo.total_files = %llu dynamicinfo.free_files = %llu dynamicinfo.avail_files = %llu", dynamicinfo.total_files, dynamicinfo.free_files, dynamicinfo.avail_files); switch (preq->rq_vers) { case NFS_V2: pres->res_statfs2.STATFS2res_u.info.tsize = NFS2_MAXDATA; pres->res_statfs2.STATFS2res_u.info.bsize = DEV_BSIZE; pres->res_statfs2.STATFS2res_u.info.blocks = dynamicinfo.total_bytes / DEV_BSIZE; pres->res_statfs2.STATFS2res_u.info.bfree = dynamicinfo.free_bytes / DEV_BSIZE; pres->res_statfs2.STATFS2res_u.info.bavail = dynamicinfo.avail_bytes / DEV_BSIZE; pres->res_statfs2.status = NFS_OK; break; case NFS_V3: nfs_SetPostOpAttr(pexport, &attr, &(pres->res_fsstat3.FSSTAT3res_u .resok.obj_attributes)); pres->res_fsstat3.FSSTAT3res_u.resok.tbytes = dynamicinfo.total_bytes; pres->res_fsstat3.FSSTAT3res_u.resok.fbytes = dynamicinfo.free_bytes; pres->res_fsstat3.FSSTAT3res_u.resok.abytes = dynamicinfo.avail_bytes; pres->res_fsstat3.FSSTAT3res_u.resok.tfiles = dynamicinfo.total_files; pres->res_fsstat3.FSSTAT3res_u.resok.ffiles = dynamicinfo.free_files; pres->res_fsstat3.FSSTAT3res_u.resok.afiles = dynamicinfo.avail_files; pres->res_fsstat3.FSSTAT3res_u.resok.invarsec = 0; /* volatile FS */ pres->res_fsstat3.status = NFS3_OK; LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> tbytes=%llu fbytes=%llu abytes=%llu", pres->res_fsstat3.FSSTAT3res_u.resok.tbytes, pres->res_fsstat3.FSSTAT3res_u.resok.fbytes, pres->res_fsstat3.FSSTAT3res_u.resok.abytes); LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> tfiles=%llu fffiles=%llu afiles=%llu", pres->res_fsstat3.FSSTAT3res_u.resok.tfiles, pres->res_fsstat3.FSSTAT3res_u.resok.ffiles, pres->res_fsstat3.FSSTAT3res_u.resok.afiles); break; } rc = NFS_REQ_OK; goto out; } } /* At this point we met an error */ if(nfs_RetryableError(cache_status)) { rc = NFS_REQ_DROP; goto out; } nfs_SetFailedStatus(pcontext, pexport, preq->rq_vers, cache_status, &pres->res_statfs2.status, &pres->res_fsstat3.status, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); rc = NFS_REQ_OK; out: /* return references */ if (pentry) cache_inode_put(pentry); return (rc); } /* nfs_Fsstat */
int _9p_statfs( _9p_request_data_t * preq9p, void * pworker_data, u32 * plenout, char * preply) { char * cursor = preq9p->_9pmsg + _9P_HDR_SIZE + _9P_TYPE_SIZE ; nfs_worker_data_t * pwkrdata = (nfs_worker_data_t *)pworker_data ; u16 * msgtag = NULL ; u32 * fid = NULL ; u64 * request_mask = NULL ; _9p_fid_t * pfid = NULL ; u32 type = 0x6969 ; /* NFS_SUPER_MAGIC for wanting of better, FSAL do not return this information */ u32 bsize = DEV_BSIZE ; u64 * blocks = NULL ; u64 * bfree = NULL ; u64 * bavail = NULL ; u64 * files = NULL ; u64 * ffree = NULL ; u64 fsid = 0LL ; u32 namelen = MAXNAMLEN ; int rc = 0 ; int err = 0 ; fsal_dynamicfsinfo_t dynamicinfo; cache_inode_status_t cache_status; if ( !preq9p || !pworker_data || !plenout || !preply ) return -1 ; /* Get data */ _9p_getptr( cursor, msgtag, u16 ) ; _9p_getptr( cursor, fid, u32 ) ; LogDebug( COMPONENT_9P, "TSTATFS: tag=%u fid=%u", (u32)*msgtag, *fid ) ; if( *fid >= _9P_FID_PER_CONN ) { err = ERANGE ; rc = _9p_rerror( preq9p, msgtag, &err, plenout, preply ) ; return rc ; } pfid = &preq9p->pconn->fids[*fid] ; /* Get the FS's stats */ if( cache_inode_statfs( pfid->pentry, &dynamicinfo, &pfid->fsal_op_context, &cache_status ) != CACHE_INODE_SUCCESS ) { err = _9p_tools_errno( cache_status ) ; ; rc = _9p_rerror( preq9p, msgtag, &err, plenout, preply ) ; return rc ; } blocks = (u64 *)&dynamicinfo.total_bytes ; bfree = (u64 *)&dynamicinfo.free_bytes ; bavail = (u64 *)&dynamicinfo.avail_bytes ; files = (u64 *)&dynamicinfo.total_files ; ffree = (u64 *)&dynamicinfo.free_files ; fsid = (u64 )pfid->attr.st_dev ; /* Build the reply */ _9p_setinitptr( cursor, preply, _9P_RSTATFS ) ; _9p_setptr( cursor, msgtag, u16 ) ; _9p_setvalue( cursor, type, u32 ) ; _9p_setvalue( cursor, bsize, u32 ) ; _9p_setptr( cursor, blocks, u64 ) ; _9p_setptr( cursor, bfree, u64 ) ; _9p_setptr( cursor, bavail, u64 ) ; _9p_setptr( cursor, files, u64 ) ; _9p_setptr( cursor, ffree, u64 ) ; _9p_setvalue( cursor, fsid, u64 ) ; _9p_setvalue( cursor, namelen, u32 ) ; _9p_setendptr( cursor, preply ) ; _9p_checkbound( cursor, preply, plenout ) ; LogDebug( COMPONENT_9P, "RSTATFS: tag=%u fid=%u", (u32)*msgtag, *fid ) ; return 1 ; }
int _9p_statfs(struct _9p_request_data *req9p, void *worker_data, u32 *plenout, char *preply) { char *cursor = req9p->_9pmsg + _9P_HDR_SIZE + _9P_TYPE_SIZE; u16 *msgtag = NULL; u32 *fid = NULL; struct _9p_fid *pfid = NULL; u32 type = 0x6969; /* NFS_SUPER_MAGIC for wanting of better, * FSAL do not return this information */ u32 bsize = 1; /* cache_inode_statfs and * FSAL already care for blocksize */ u64 *blocks = NULL; u64 *bfree = NULL; u64 *bavail = NULL; u64 *files = NULL; u64 *ffree = NULL; u64 fsid = 0LL; u32 namelen = MAXNAMLEN; fsal_dynamicfsinfo_t dynamicinfo; cache_inode_status_t cache_status; /* Get data */ _9p_getptr(cursor, msgtag, u16); _9p_getptr(cursor, fid, u32); LogDebug(COMPONENT_9P, "TSTATFS: tag=%u fid=%u", (u32) *msgtag, *fid); if (*fid >= _9P_FID_PER_CONN) return _9p_rerror(req9p, worker_data, msgtag, ERANGE, plenout, preply); pfid = req9p->pconn->fids[*fid]; if (pfid == NULL) return _9p_rerror(req9p, worker_data, msgtag, EINVAL, plenout, preply); /* Get the FS's stats */ cache_status = cache_inode_statfs(pfid->pentry, &dynamicinfo, &pfid->op_context); if (cache_status != CACHE_INODE_SUCCESS) return _9p_rerror(req9p, worker_data, msgtag, _9p_tools_errno(cache_status), plenout, preply); blocks = (u64 *) &dynamicinfo.total_bytes; bfree = (u64 *) &dynamicinfo.free_bytes; bavail = (u64 *) &dynamicinfo.avail_bytes; files = (u64 *) &dynamicinfo.total_files; ffree = (u64 *) &dynamicinfo.free_files; fsid = (u64) pfid->pentry->obj_handle->attributes.rawdev.major; /* Build the reply */ _9p_setinitptr(cursor, preply, _9P_RSTATFS); _9p_setptr(cursor, msgtag, u16); _9p_setvalue(cursor, type, u32); _9p_setvalue(cursor, bsize, u32); _9p_setptr(cursor, blocks, u64); _9p_setptr(cursor, bfree, u64); _9p_setptr(cursor, bavail, u64); _9p_setptr(cursor, files, u64); _9p_setptr(cursor, ffree, u64); _9p_setvalue(cursor, fsid, u64); _9p_setvalue(cursor, namelen, u32); _9p_setendptr(cursor, preply); _9p_checkbound(cursor, preply, plenout); LogDebug(COMPONENT_9P, "RSTATFS: tag=%u fid=%u", (u32) *msgtag, *fid); return 1; }
int nfs3_fsstat(nfs_arg_t *arg, struct svc_req *req, nfs_res_t *res) { fsal_dynamicfsinfo_t dynamicinfo; cache_inode_status_t cache_status; cache_entry_t *entry = NULL; int rc = NFS_REQ_OK; if (isDebug(COMPONENT_NFSPROTO)) { char str[LEN_FH_STR]; nfs_FhandleToStr(req->rq_vers, &(arg->arg_fsstat3.fsroot), NULL, str); LogDebug(COMPONENT_NFSPROTO, "REQUEST PROCESSING: Calling nfs3_fsstat handle: %s", str); } /* to avoid setting it on each error case */ res->res_fsstat3.FSSTAT3res_u.resfail.obj_attributes.attributes_follow = FALSE; entry = nfs3_FhandleToCache(&arg->arg_fsstat3.fsroot, &res->res_fsstat3.status, &rc); if (entry == NULL) { /* Status and rc have been set by nfs3_FhandleToCache */ goto out; } /* Get statistics and convert from cache */ cache_status = cache_inode_statfs(entry, &dynamicinfo); if (cache_status == CACHE_INODE_SUCCESS) { LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> dynamicinfo.total_bytes=%" PRIu64 " dynamicinfo.free_bytes=%" PRIu64 " dynamicinfo.avail_bytes=%" PRIu64, dynamicinfo.total_bytes, dynamicinfo.free_bytes, dynamicinfo.avail_bytes); LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> dynamicinfo.total_files=%" PRIu64 " dynamicinfo.free_files=%" PRIu64 " dynamicinfo.avail_files=%" PRIu64, dynamicinfo.total_files, dynamicinfo.free_files, dynamicinfo.avail_files); nfs_SetPostOpAttr(entry, &(res->res_fsstat3.FSSTAT3res_u.resok. obj_attributes)); res->res_fsstat3.FSSTAT3res_u.resok.tbytes = dynamicinfo.total_bytes; res->res_fsstat3.FSSTAT3res_u.resok.fbytes = dynamicinfo.free_bytes; res->res_fsstat3.FSSTAT3res_u.resok.abytes = dynamicinfo.avail_bytes; res->res_fsstat3.FSSTAT3res_u.resok.tfiles = dynamicinfo.total_files; res->res_fsstat3.FSSTAT3res_u.resok.ffiles = dynamicinfo.free_files; res->res_fsstat3.FSSTAT3res_u.resok.afiles = dynamicinfo.avail_files; /* volatile FS */ res->res_fsstat3.FSSTAT3res_u.resok.invarsec = 0; res->res_fsstat3.status = NFS3_OK; LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> tbytes=%llu fbytes=%llu abytes=%llu", res->res_fsstat3.FSSTAT3res_u.resok.tbytes, res->res_fsstat3.FSSTAT3res_u.resok.fbytes, res->res_fsstat3.FSSTAT3res_u.resok.abytes); LogFullDebug(COMPONENT_NFSPROTO, "nfs_Fsstat --> tfiles=%llu fffiles=%llu afiles=%llu", res->res_fsstat3.FSSTAT3res_u.resok.tfiles, res->res_fsstat3.FSSTAT3res_u.resok.ffiles, res->res_fsstat3.FSSTAT3res_u.resok.afiles); rc = NFS_REQ_OK; goto out; } /* At this point we met an error */ if (nfs_RetryableError(cache_status)) { rc = NFS_REQ_DROP; goto out; } res->res_fsstat3.status = nfs3_Errno(cache_status); rc = NFS_REQ_OK; out: /* return references */ if (entry) cache_inode_put(entry); return rc; } /* nfs3_fsstat */