ext4: avoid s_mb_prefetch to be zero in individual scenarios
[linux-2.6-microblaze.git] / fs / utimes.c
index c667517..fd3cc42 100644 (file)
@@ -16,21 +16,26 @@ static bool nsec_valid(long nsec)
        return nsec >= 0 && nsec <= 999999999;
 }
 
-static int utimes_common(const struct path *path, struct timespec64 *times)
+int vfs_utimes(const struct path *path, struct timespec64 *times)
 {
        int error;
        struct iattr newattrs;
        struct inode *inode = path->dentry->d_inode;
        struct inode *delegated_inode = NULL;
 
+       if (times) {
+               if (!nsec_valid(times[0].tv_nsec) ||
+                   !nsec_valid(times[1].tv_nsec))
+                       return -EINVAL;
+               if (times[0].tv_nsec == UTIME_NOW &&
+                   times[1].tv_nsec == UTIME_NOW)
+                       times = NULL;
+       }
+
        error = mnt_want_write(path->mnt);
        if (error)
                goto out;
 
-       if (times && times[0].tv_nsec == UTIME_NOW &&
-                    times[1].tv_nsec == UTIME_NOW)
-               times = NULL;
-
        newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME;
        if (times) {
                if (times[0].tv_nsec == UTIME_OMIT)
@@ -76,9 +81,6 @@ static int do_utimes_path(int dfd, const char __user *filename,
        struct path path;
        int lookup_flags = 0, error;
 
-       if (times &&
-           (!nsec_valid(times[0].tv_nsec) || !nsec_valid(times[1].tv_nsec)))
-               return -EINVAL;
        if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH))
                return -EINVAL;
 
@@ -92,7 +94,7 @@ retry:
        if (error)
                return error;
 
-       error = utimes_common(&path, times);
+       error = vfs_utimes(&path, times);
        path_put(&path);
        if (retry_estale(error, lookup_flags)) {
                lookup_flags |= LOOKUP_REVAL;
@@ -107,16 +109,13 @@ static int do_utimes_fd(int fd, struct timespec64 *times, int flags)
        struct fd f;
        int error;
 
-       if (times &&
-           (!nsec_valid(times[0].tv_nsec) || !nsec_valid(times[1].tv_nsec)))
-               return -EINVAL;
        if (flags)
                return -EINVAL;
 
        f = fdget(fd);
        if (!f.file)
                return -EBADF;
-       error = utimes_common(&f.file->f_path, times);
+       error = vfs_utimes(&f.file->f_path, times);
        fdput(f);
        return error;
 }