mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-11-10 14:50:58 +00:00
Updated to clearly output message about the file descriptor type(pseudo/physical)
This commit is contained in:
parent
944c1fd148
commit
6edf3d6427
@ -452,7 +452,7 @@ FdManager::~FdManager()
|
||||
|
||||
FdEntity* FdManager::GetFdEntity(const char* path, int& existfd, bool newfd, bool lock_already_held)
|
||||
{
|
||||
S3FS_PRN_INFO3("[path=%s][fd=%d]", SAFESTRPTR(path), existfd);
|
||||
S3FS_PRN_INFO3("[path=%s][pseudo_fd=%d]", SAFESTRPTR(path), existfd);
|
||||
|
||||
if(!path || '\0' == path[0]){
|
||||
return NULL;
|
||||
@ -590,7 +590,7 @@ FdEntity* FdManager::Open(int& fd, const char* path, headers_t* pmeta, off_t siz
|
||||
//
|
||||
FdEntity* FdManager::GetExistFdEntity(const char* path, int existfd)
|
||||
{
|
||||
S3FS_PRN_DBG("[path=%s][existfd=%d]", SAFESTRPTR(path), existfd);
|
||||
S3FS_PRN_DBG("[path=%s][pseudo_fd=%d]", SAFESTRPTR(path), existfd);
|
||||
|
||||
AutoLock auto_lock(&FdManager::fd_manager_lock);
|
||||
|
||||
|
@ -91,7 +91,7 @@ bool AutoFdEntity::Attach(const char* path, int existfd)
|
||||
Close();
|
||||
|
||||
if(NULL == (pFdEntity = FdManager::get()->GetFdEntity(path, existfd, false))){
|
||||
S3FS_PRN_DBG("Could not find fd entity object(file=%s, existfd=%d)", path, existfd);
|
||||
S3FS_PRN_DBG("Could not find fd entity object(file=%s, pseudo_fd=%d)", path, existfd);
|
||||
return false;
|
||||
}
|
||||
pseudo_fd = existfd;
|
||||
|
@ -84,7 +84,7 @@ ino_t FdEntity::GetInode(int fd)
|
||||
|
||||
struct stat st;
|
||||
if(0 != fstat(fd, &st)){
|
||||
S3FS_PRN_ERR("could not get stat for file descriptor(%d) by errno(%d).", fd, errno);
|
||||
S3FS_PRN_ERR("could not get stat for physical file descriptor(%d) by errno(%d).", fd, errno);
|
||||
return 0;
|
||||
}
|
||||
return st.st_ino;
|
||||
@ -429,12 +429,12 @@ int FdEntity::Open(headers_t* pmeta, off_t size, time_t time, int flags, AutoLoc
|
||||
if(0 <= size && pagelist.Size() != size){
|
||||
// truncate temporary file size
|
||||
if(-1 == ftruncate(physical_fd, size)){
|
||||
S3FS_PRN_ERR("failed to truncate temporary file(%d) by errno(%d).", physical_fd, errno);
|
||||
S3FS_PRN_ERR("failed to truncate temporary file(physical_fd=%d) by errno(%d).", physical_fd, errno);
|
||||
return -errno;
|
||||
}
|
||||
// resize page list
|
||||
if(!pagelist.Resize(size, false, true)){ // Areas with increased size are modified
|
||||
S3FS_PRN_ERR("failed to truncate temporary file information(%d).", physical_fd);
|
||||
S3FS_PRN_ERR("failed to truncate temporary file information(physical_fd=%d).", physical_fd);
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
@ -1152,7 +1152,7 @@ int FdEntity::NoCacheLoadAndPost(PseudoFdInfo* pseudo_obj, off_t start, off_t si
|
||||
// after this, file length is (offset + size), but file does not use any disk space.
|
||||
//
|
||||
if(-1 == ftruncate(tmpfd, 0) || -1 == ftruncate(tmpfd, (offset + oneread))){
|
||||
S3FS_PRN_ERR("failed to truncate temporary file(%d).", tmpfd);
|
||||
S3FS_PRN_ERR("failed to truncate temporary file(physical_fd=%d).", tmpfd);
|
||||
result = -EIO;
|
||||
break;
|
||||
}
|
||||
@ -1161,14 +1161,14 @@ int FdEntity::NoCacheLoadAndPost(PseudoFdInfo* pseudo_obj, off_t start, off_t si
|
||||
if(0 < need_load_size){
|
||||
S3fsCurl s3fscurl;
|
||||
if(0 != (result = s3fscurl.GetObjectRequest(path.c_str(), tmpfd, offset, oneread))){
|
||||
S3FS_PRN_ERR("failed to get object(start=%lld, size=%lld) for file(%d).", static_cast<long long int>(offset), static_cast<long long int>(oneread), tmpfd);
|
||||
S3FS_PRN_ERR("failed to get object(start=%lld, size=%lld) for file(physical_fd=%d).", static_cast<long long int>(offset), static_cast<long long int>(oneread), tmpfd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// initialize fd without loading
|
||||
if(0 < over_size){
|
||||
if(0 != (result = FdEntity::FillFile(tmpfd, 0, over_size, offset + need_load_size))){
|
||||
S3FS_PRN_ERR("failed to fill rest bytes for fd(%d). errno(%d)", tmpfd, result);
|
||||
S3FS_PRN_ERR("failed to fill rest bytes for physical_fd(%d). errno(%d)", tmpfd, result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1177,7 +1177,7 @@ int FdEntity::NoCacheLoadAndPost(PseudoFdInfo* pseudo_obj, off_t start, off_t si
|
||||
}
|
||||
// single area upload by multipart post
|
||||
if(0 != (result = NoCacheMultipartPost(pseudo_obj, upload_fd, offset, oneread))){
|
||||
S3FS_PRN_ERR("failed to multipart post(start=%lld, size=%lld) for file(%d).", static_cast<long long int>(offset), static_cast<long long int>(oneread), upload_fd);
|
||||
S3FS_PRN_ERR("failed to multipart post(start=%lld, size=%lld) for file(physical_fd=%d).", static_cast<long long int>(offset), static_cast<long long int>(oneread), upload_fd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1210,7 +1210,7 @@ int FdEntity::NoCacheLoadAndPost(PseudoFdInfo* pseudo_obj, off_t start, off_t si
|
||||
|
||||
// fd data do empty
|
||||
if(-1 == ftruncate(physical_fd, 0)){
|
||||
S3FS_PRN_ERR("failed to truncate file(%d), but continue...", physical_fd);
|
||||
S3FS_PRN_ERR("failed to truncate file(physical_fd=%d), but continue...", physical_fd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1364,7 +1364,7 @@ int FdEntity::RowFlush(int fd, const char* tpath, bool force_sync)
|
||||
}else{
|
||||
// no enough disk space
|
||||
if(nomultipart){
|
||||
S3FS_PRN_WARN("Not enough local storage to flush: [path=%s][fd=%d]", path.c_str(), fd);
|
||||
S3FS_PRN_WARN("Not enough local storage to flush: [path=%s][pseudo_fd=%d][physical_fd=%d]", path.c_str(), fd, physical_fd);
|
||||
return -ENOSPC; // No space left on device
|
||||
}
|
||||
if(0 != (result = NoCachePreMultipartPost(pseudo_obj))){
|
||||
@ -1473,20 +1473,20 @@ int FdEntity::RowFlush(int fd, const char* tpath, bool force_sync)
|
||||
|
||||
if(0 < untreated_size){
|
||||
if(0 != (result = NoCacheMultipartPost(pseudo_obj, physical_fd, untreated_start, untreated_size))){
|
||||
S3FS_PRN_ERR("failed to multipart post(start=%lld, size=%lld) for file(%d).", static_cast<long long int>(untreated_start), static_cast<long long int>(untreated_size), physical_fd);
|
||||
S3FS_PRN_ERR("failed to multipart post(start=%lld, size=%lld) for file(physical_fd=%d).", static_cast<long long int>(untreated_start), static_cast<long long int>(untreated_size), physical_fd);
|
||||
return result;
|
||||
}
|
||||
pseudo_obj->ClearUntreated();
|
||||
}
|
||||
// complete multipart uploading.
|
||||
if(0 != (result = NoCacheCompleteMultipartPost(pseudo_obj))){
|
||||
S3FS_PRN_ERR("failed to complete(finish) multipart post for file(%d).", physical_fd);
|
||||
S3FS_PRN_ERR("failed to complete(finish) multipart post for file(physical_fd=%d).", physical_fd);
|
||||
return result;
|
||||
}
|
||||
// truncate file to zero
|
||||
if(-1 == ftruncate(physical_fd, 0)){
|
||||
// So the file has already been removed, skip error.
|
||||
S3FS_PRN_ERR("failed to truncate file(%d) to zero, but continue...", physical_fd);
|
||||
S3FS_PRN_ERR("failed to truncate file(physical_fd=%d) to zero, but continue...", physical_fd);
|
||||
}
|
||||
// put pading headers
|
||||
if(0 != (result = UploadPendingMeta())){
|
||||
@ -1512,7 +1512,7 @@ bool FdEntity::ReserveDiskSpace(off_t size)
|
||||
// try to clear all cache for this fd.
|
||||
pagelist.Init(pagelist.Size(), false, false);
|
||||
if(-1 == ftruncate(physical_fd, 0) || -1 == ftruncate(physical_fd, pagelist.Size())){
|
||||
S3FS_PRN_ERR("failed to truncate temporary file(%d).", physical_fd);
|
||||
S3FS_PRN_ERR("failed to truncate temporary file(physical_fd=%d).", physical_fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1610,7 +1610,7 @@ ssize_t FdEntity::Write(int fd, const char* bytes, off_t start, size_t size)
|
||||
if(pagelist.Size() < start){
|
||||
// grow file size
|
||||
if(-1 == ftruncate(physical_fd, start)){
|
||||
S3FS_PRN_ERR("failed to truncate temporary file(%d).", physical_fd);
|
||||
S3FS_PRN_ERR("failed to truncate temporary file(physical_fd=%d).", physical_fd);
|
||||
return -errno;
|
||||
}
|
||||
// add new area
|
||||
@ -1693,7 +1693,7 @@ ssize_t FdEntity::Write(int fd, const char* bytes, off_t start, size_t size)
|
||||
if(S3fsCurl::GetMultipartSize() <= untreated_size){
|
||||
// over one multipart size
|
||||
if(0 != (result = NoCacheMultipartPost(pseudo_obj, physical_fd, untreated_start, untreated_size))){
|
||||
S3FS_PRN_ERR("failed to multipart post(start=%lld, size=%lld) for file(%d).", static_cast<long long int>(untreated_start), static_cast<long long int>(untreated_size), physical_fd);
|
||||
S3FS_PRN_ERR("failed to multipart post(start=%lld, size=%lld) for file(physical_fd=%d).", static_cast<long long int>(untreated_start), static_cast<long long int>(untreated_size), physical_fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1702,7 +1702,7 @@ ssize_t FdEntity::Write(int fd, const char* bytes, off_t start, size_t size)
|
||||
// after this, file length is (offset + size), but file does not use any disk space.
|
||||
//
|
||||
if(-1 == ftruncate(physical_fd, 0) || -1 == ftruncate(physical_fd, (untreated_start + untreated_size))){
|
||||
S3FS_PRN_ERR("failed to truncate file(%d).", physical_fd);
|
||||
S3FS_PRN_ERR("failed to truncate file(physical_fd=%d).", physical_fd);
|
||||
return -errno;
|
||||
}
|
||||
pseudo_obj->SetUntreated(untreated_start + untreated_size, 0);
|
||||
|
@ -186,7 +186,7 @@ bool PageList::GetSparseFilePages(int fd, size_t file_size, fdpage_list_t& spars
|
||||
off_t hole_pos = lseek(fd, 0, SEEK_HOLE);
|
||||
off_t data_pos = lseek(fd, 0, SEEK_DATA);
|
||||
if(-1 == hole_pos && -1 == data_pos){
|
||||
S3FS_PRN_ERR("Could not find the first position both HOLE and DATA in the file(fd=%d).", fd);
|
||||
S3FS_PRN_ERR("Could not find the first position both HOLE and DATA in the file(physical_fd=%d).", fd);
|
||||
return false;
|
||||
}else if(-1 == hole_pos){
|
||||
is_hole = false;
|
||||
@ -231,7 +231,7 @@ bool PageList::CheckZeroAreaInFile(int fd, off_t start, size_t bytes)
|
||||
bool found_bad_data = false;
|
||||
ssize_t read_bytes;
|
||||
if(-1 == (read_bytes = pread(fd, readbuff, check_bytes, (start + comp_bytes)))){
|
||||
S3FS_PRN_ERR("Something error is occurred in reading %zu bytes at %lld from file(%d).", check_bytes, static_cast<long long int>(start + comp_bytes), fd);
|
||||
S3FS_PRN_ERR("Something error is occurred in reading %zu bytes at %lld from file(physical_fd=%d).", check_bytes, static_cast<long long int>(start + comp_bytes), fd);
|
||||
found_bad_data = true;
|
||||
}else{
|
||||
check_bytes = static_cast<size_t>(read_bytes);
|
||||
@ -941,7 +941,7 @@ bool PageList::CompareSparseFile(int fd, size_t file_size, fdpage_list_t& err_ar
|
||||
// are assigned to any holes.
|
||||
fdpage_list_t sparse_list;
|
||||
if(!PageList::GetSparseFilePages(fd, file_size, sparse_list)){
|
||||
S3FS_PRN_ERR("Something error is occurred in parsing hole/data of the cache file(%d).", fd);
|
||||
S3FS_PRN_ERR("Something error is occurred in parsing hole/data of the cache file(physical_fd=%d).", fd);
|
||||
|
||||
fdpage page(0, static_cast<off_t>(file_size), false, false);
|
||||
err_area_list.push_back(page);
|
||||
|
16
src/s3fs.cpp
16
src/s3fs.cpp
@ -2313,12 +2313,12 @@ static int s3fs_read(const char* _path, char* buf, size_t size, off_t offset, st
|
||||
WTF8_ENCODE(path)
|
||||
ssize_t res;
|
||||
|
||||
S3FS_PRN_DBG("[path=%s][size=%zu][offset=%lld][fd=%llu]", path, size, static_cast<long long>(offset), (unsigned long long)(fi->fh));
|
||||
S3FS_PRN_DBG("[path=%s][size=%zu][offset=%lld][pseudo_fd=%llu]", path, size, static_cast<long long>(offset), (unsigned long long)(fi->fh));
|
||||
|
||||
AutoFdEntity autoent;
|
||||
FdEntity* ent;
|
||||
if(NULL == (ent = autoent.GetExistFdEntity(path, static_cast<int>(fi->fh)))){
|
||||
S3FS_PRN_ERR("could not find opened fd(%s)", path);
|
||||
S3FS_PRN_ERR("could not find opened pseudo_fd(=%llu) for path(%s)", (unsigned long long)(fi->fh), path);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@ -2341,12 +2341,12 @@ static int s3fs_write(const char* _path, const char* buf, size_t size, off_t off
|
||||
WTF8_ENCODE(path)
|
||||
ssize_t res;
|
||||
|
||||
S3FS_PRN_DBG("[path=%s][size=%zu][offset=%lld][fd=%llu]", path, size, static_cast<long long int>(offset), (unsigned long long)(fi->fh));
|
||||
S3FS_PRN_DBG("[path=%s][size=%zu][offset=%lld][pseudo_fd=%llu]", path, size, static_cast<long long int>(offset), (unsigned long long)(fi->fh));
|
||||
|
||||
AutoFdEntity autoent;
|
||||
FdEntity* ent;
|
||||
if(NULL == (ent = autoent.GetExistFdEntity(path, static_cast<int>(fi->fh)))){
|
||||
S3FS_PRN_ERR("could not find opened fd(%s)", path);
|
||||
S3FS_PRN_ERR("could not find opened pseudo_fd(%llu) for path(%s)", (unsigned long long)(fi->fh), path);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@ -2387,7 +2387,7 @@ static int s3fs_flush(const char* _path, struct fuse_file_info* fi)
|
||||
WTF8_ENCODE(path)
|
||||
int result;
|
||||
|
||||
S3FS_PRN_INFO("[path=%s][fd=%llu]", path, (unsigned long long)(fi->fh));
|
||||
S3FS_PRN_INFO("[path=%s][pseudo_fd=%llu]", path, (unsigned long long)(fi->fh));
|
||||
|
||||
int mask = (O_RDONLY != (fi->flags & O_ACCMODE) ? W_OK : R_OK);
|
||||
if(0 != (result = check_parent_object_access(path, X_OK))){
|
||||
@ -2423,7 +2423,7 @@ static int s3fs_fsync(const char* _path, int datasync, struct fuse_file_info* fi
|
||||
WTF8_ENCODE(path)
|
||||
int result = 0;
|
||||
|
||||
S3FS_PRN_INFO("[path=%s][fd=%llu]", path, (unsigned long long)(fi->fh));
|
||||
S3FS_PRN_INFO("[path=%s][pseudo_fd=%llu]", path, (unsigned long long)(fi->fh));
|
||||
|
||||
AutoFdEntity autoent;
|
||||
FdEntity* ent;
|
||||
@ -2445,7 +2445,7 @@ static int s3fs_fsync(const char* _path, int datasync, struct fuse_file_info* fi
|
||||
static int s3fs_release(const char* _path, struct fuse_file_info* fi)
|
||||
{
|
||||
WTF8_ENCODE(path)
|
||||
S3FS_PRN_INFO("[path=%s][fd=%llu]", path, (unsigned long long)(fi->fh));
|
||||
S3FS_PRN_INFO("[path=%s][pseudo_fd=%llu]", path, (unsigned long long)(fi->fh));
|
||||
|
||||
// [NOTE]
|
||||
// All opened file's stats is cached with no truncate flag.
|
||||
@ -2470,7 +2470,7 @@ static int s3fs_release(const char* _path, struct fuse_file_info* fi)
|
||||
// destroyed here.
|
||||
//
|
||||
if(!autoent.Attach(path, static_cast<int>(fi->fh))){
|
||||
S3FS_PRN_ERR("could not find pseudo fd(file=%s, fd=%d)", path, static_cast<int>(fi->fh));
|
||||
S3FS_PRN_ERR("could not find pseudo_fd(%llu) for path(%s)", (unsigned long long)(fi->fh), path);
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user