浏览代码

HDFS-858. Incorrect return codes for fuse-dfs. Contributed by Brian Bockelman.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@921596 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 15 年之前
父节点
当前提交
e7f6a9fbac
共有 3 个文件被更改,包括 18 次插入5 次删除
  1. 3 0
      CHANGES.txt
  2. 5 1
      src/contrib/fuse-dfs/src/fuse_impls_open.c
  3. 10 4
      src/contrib/fuse-dfs/src/fuse_impls_write.c

+ 3 - 0
CHANGES.txt

@@ -182,6 +182,9 @@ Trunk (unreleased changes)
     HDFS-857. Incorrect type for fuse-dfs capacity can cause "df" to return
     negative values on 32-bit machines. (Brian Bockelman via tomwhite)
 
+    HDFS-858. Incorrect return codes for fuse-dfs. (Brian Bockelman via
+    tomwhite)
+
 Release 0.21.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 5 - 1
src/contrib/fuse-dfs/src/fuse_impls_open.c

@@ -52,7 +52,11 @@ int dfs_open(const char *path, struct fuse_file_info *fi)
 
   if ((fh->hdfsFH = hdfsOpenFile(fh->fs, path, flags,  0, 0, 0)) == NULL) {
     syslog(LOG_ERR, "ERROR: could not connect open file %s:%d\n", __FILE__, __LINE__);
-    return -EIO;
+    syslog(LOG_ERR, "ERROR: errno %d\n", errno);
+    if (errno == 0 || errno == EINTERNAL) {
+      return -EIO;
+    }
+    return -errno;
   }
 
   // 

+ 10 - 4
src/contrib/fuse-dfs/src/fuse_impls_write.c

@@ -53,15 +53,21 @@ int dfs_write(const char *path, const char *buf, size_t size,
   tOffset cur_offset = hdfsTell(fh->fs, file_handle);
   if (cur_offset != offset) {
     syslog(LOG_ERR, "ERROR: user trying to random access write to a file %d!=%d for %s %s:%d\n",(int)cur_offset, (int)offset,path, __FILE__, __LINE__);
-    ret =  -EIO;
+    ret =  -ENOTSUP;
   } else {
     length = hdfsWrite(fh->fs, file_handle, buf, size);
     if (length <= 0) {
-      syslog(LOG_ERR, "ERROR: fuse problem - could not write all the bytes for %s %d!=%d%s:%d\n",path,length,(int)size, __FILE__, __LINE__);
-      ret = -EIO;
+      syslog(LOG_ERR, "ERROR: could not write all the bytes for %s %d!=%d%s:%d\n", path, length, (int)size, __FILE__, __LINE__);
+      syslog(LOG_ERR, "ERROR: errno %d\n", errno);
+      if (errno == 0 || errno == EINTERNAL) {
+        ret = -EIO;
+      } else {
+        ret = -errno;
+      }
     } 
     if (length != size) {
-      syslog(LOG_ERR, "WARN: fuse problem - could not write all the bytes for %s %d!=%d%s:%d\n",path,length,(int)size, __FILE__, __LINE__);
+      syslog(LOG_ERR, "ERROR: could not write all the bytes for %s %d!=%d%s:%d\n", path, length, (int)size, __FILE__, __LINE__);
+      syslog(LOG_ERR, "ERROR: errno - %d\n", errno);
     }
   }