Linux: Handle llseek failure
[openafs.git] / src / afs / LINUX / osi_file.c
index 378cda8..31ef063 100644 (file)
@@ -32,7 +32,7 @@ extern struct cred *cache_creds;
 #endif
 
 struct file *
-afs_linux_raw_open(afs_dcache_id_t *ainode, ino_t *hint)
+afs_linux_raw_open(afs_dcache_id_t *ainode)
 {
     struct inode *tip = NULL;
     struct dentry *dp = NULL;
@@ -51,7 +51,7 @@ afs_linux_raw_open(afs_dcache_id_t *ainode, ino_t *hint)
            osi_Panic("Can't get dentry\n");
     tip = dp->d_inode;
 #endif
-    tip->i_flags |= MS_NOATIME;        /* Disable updating access times. */
+    tip->i_flags |= S_NOATIME; /* Disable updating access times. */
 
 #if defined(STRUCT_TASK_HAS_CRED)
     /* Use stashed credentials - prevent selinux/apparmor problems  */
@@ -65,8 +65,6 @@ afs_linux_raw_open(afs_dcache_id_t *ainode, ino_t *hint)
 #else
        osi_Panic("Can't open inode %d\n", (int) ainode->ufs);
 #endif
-    if (hint)
-       *hint = tip->i_ino;
     return filp;
 }
 
@@ -94,7 +92,7 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
     }
     memset(afile, 0, sizeof(struct osi_file));
 
-    afile->filp = afs_linux_raw_open(ainode, &afile->inum);
+    afile->filp = afs_linux_raw_open(ainode);
     afile->size = i_size_read(FILE_INODE(afile->filp));
     AFS_GLOCK();
     afile->offset = 0;
@@ -191,14 +189,14 @@ osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
        return code;
     ObtainWriteLock(&afs_xosi, 321);
     AFS_GUNLOCK();
-#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
-    down_write(&inode->i_alloc_sem);
-#endif
 #ifdef STRUCT_INODE_HAS_I_MUTEX
     mutex_lock(&inode->i_mutex);
 #else
     down(&inode->i_sem);
 #endif
+#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
+    down_write(&inode->i_alloc_sem);
+#endif
     newattrs.ia_size = asize;
     newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
     newattrs.ia_ctime = CURRENT_TIME;
@@ -220,14 +218,14 @@ osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
     if (!code)
        truncate_inode_pages(&inode->i_data, asize);
     code = -code;
+#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
+    up_write(&inode->i_alloc_sem);
+#endif
 #ifdef STRUCT_INODE_HAS_I_MUTEX
     mutex_unlock(&inode->i_mutex);
 #else
     up(&inode->i_sem);
 #endif
-#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
-    up_write(&inode->i_alloc_sem);
-#endif
     AFS_GLOCK();
     ReleaseWriteLock(&afs_xosi);
     return code;
@@ -389,7 +387,8 @@ osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw)
     /* seek to the desired position. Return -1 on error. */
     if (filp->f_op->llseek) {
        if (filp->f_op->llseek(filp, (loff_t) uiop->uio_offset, 0) != uiop->uio_offset)
-           return -1;
+           code = -1;
+           goto out;
     } else
        filp->f_pos = uiop->uio_offset;
 
@@ -427,6 +426,7 @@ osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw)
        code = 0;
     }
 
+out:
     if (uiop->uio_seg == AFS_UIOSYS)
        TO_KERNEL_SPACE();