These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / fs / hpfs / namei.c
index a0872f2..bffb908 100644 (file)
@@ -8,6 +8,17 @@
 #include <linux/sched.h>
 #include "hpfs_fn.h"
 
+static void hpfs_update_directory_times(struct inode *dir)
+{
+       time_t t = get_seconds();
+       if (t == dir->i_mtime.tv_sec &&
+           t == dir->i_ctime.tv_sec)
+               return;
+       dir->i_mtime.tv_sec = dir->i_ctime.tv_sec = t;
+       dir->i_mtime.tv_nsec = dir->i_ctime.tv_nsec = 0;
+       hpfs_write_inode_nolock(dir);
+}
+
 static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
        const unsigned char *name = dentry->d_name.name;
@@ -99,6 +110,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
                result->i_mode = mode | S_IFDIR;
                hpfs_write_inode_nolock(result);
        }
+       hpfs_update_directory_times(dir);
        d_instantiate(dentry, result);
        hpfs_unlock(dir->i_sb);
        return 0;
@@ -187,6 +199,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, b
                result->i_mode = mode | S_IFREG;
                hpfs_write_inode_nolock(result);
        }
+       hpfs_update_directory_times(dir);
        d_instantiate(dentry, result);
        hpfs_unlock(dir->i_sb);
        return 0;
@@ -214,8 +227,6 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, de
        int err;
        if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err;
        if (hpfs_sb(dir->i_sb)->sb_eas < 2) return -EPERM;
-       if (!new_valid_dev(rdev))
-               return -EINVAL;
        hpfs_lock(dir->i_sb);
        err = -ENOSPC;
        fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
@@ -262,6 +273,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, de
        insert_inode_hash(result);
 
        hpfs_write_inode_nolock(result);
+       hpfs_update_directory_times(dir);
        d_instantiate(dentry, result);
        brelse(bh);
        hpfs_unlock(dir->i_sb);
@@ -340,6 +352,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
        insert_inode_hash(result);
 
        hpfs_write_inode_nolock(result);
+       hpfs_update_directory_times(dir);
        d_instantiate(dentry, result);
        hpfs_unlock(dir->i_sb);
        return 0;
@@ -362,12 +375,11 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
        struct inode *inode = d_inode(dentry);
        dnode_secno dno;
        int r;
-       int rep = 0;
        int err;
 
        hpfs_lock(dir->i_sb);
        hpfs_adjust_length(name, &len);
-again:
+
        err = -ENOENT;
        de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh);
        if (!de)
@@ -387,33 +399,9 @@ again:
                hpfs_error(dir->i_sb, "there was error when removing dirent");
                err = -EFSERROR;
                break;
-       case 2:         /* no space for deleting, try to truncate file */
-
+       case 2:         /* no space for deleting */
                err = -ENOSPC;
-               if (rep++)
-                       break;
-
-               dentry_unhash(dentry);
-               if (!d_unhashed(dentry)) {
-                       hpfs_unlock(dir->i_sb);
-                       return -ENOSPC;
-               }
-               if (generic_permission(inode, MAY_WRITE) ||
-                   !S_ISREG(inode->i_mode) ||
-                   get_write_access(inode)) {
-                       d_rehash(dentry);
-               } else {
-                       struct iattr newattrs;
-                       /*pr_info("truncating file before delete.\n");*/
-                       newattrs.ia_size = 0;
-                       newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
-                       err = notify_change(dentry, &newattrs, NULL);
-                       put_write_access(inode);
-                       if (!err)
-                               goto again;
-               }
-               hpfs_unlock(dir->i_sb);
-               return -ENOSPC;
+               break;
        default:
                drop_nlink(inode);
                err = 0;
@@ -423,6 +411,8 @@ again:
 out1:
        hpfs_brelse4(&qbh);
 out:
+       if (!err)
+               hpfs_update_directory_times(dir);
        hpfs_unlock(dir->i_sb);
        return err;
 }
@@ -477,6 +467,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
 out1:
        hpfs_brelse4(&qbh);
 out:
+       if (!err)
+               hpfs_update_directory_times(dir);
        hpfs_unlock(dir->i_sb);
        return err;
 }
@@ -595,7 +587,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                goto end1;
        }
 
-       end:
+end:
        hpfs_i(i)->i_parent_dir = new_dir->i_ino;
        if (S_ISDIR(i->i_mode)) {
                inc_nlink(new_dir);
@@ -610,6 +602,10 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                brelse(bh);
        }
 end1:
+       if (!err) {
+               hpfs_update_directory_times(old_dir);
+               hpfs_update_directory_times(new_dir);
+       }
        hpfs_unlock(i->i_sb);
        return err;
 }