diff mbox

fuse: fix time_to_jiffies nsec sanity check

Message ID 1484323110-73569-1-git-send-email-dsheets@docker.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Sheets Jan. 13, 2017, 3:58 p.m. UTC
bcb6f6d2b9c299db32b20f4357c36a101e7f0293 introduced clamped nsec values
in time_to_jiffies but used the max of nsec and NSEC_PER_SEC - 1 instead
of the min. Because of this, dentries would stay in the cache longer
than requested and go stale in scenarios that relied on their timely
eviction.

Signed-off-by: David Sheets <dsheets@docker.com>
---
 fs/fuse/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Miklos Szeredi Jan. 13, 2017, 4:21 p.m. UTC | #1
On Fri, Jan 13, 2017 at 4:58 PM, David Sheets <david.sheets@docker.com> wrote:
> bcb6f6d2b9c299db32b20f4357c36a101e7f0293 introduced clamped nsec values
> in time_to_jiffies but used the max of nsec and NSEC_PER_SEC - 1 instead
> of the min. Because of this, dentries would stay in the cache longer
> than requested and go stale in scenarios that relied on their timely
> eviction.

Thanks, applied.

Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 096f799..642c57b 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -68,7 +68,7 @@  static u64 time_to_jiffies(u64 sec, u32 nsec)
 	if (sec || nsec) {
 		struct timespec64 ts = {
 			sec,
-			max_t(u32, nsec, NSEC_PER_SEC - 1)
+			min_t(u32, nsec, NSEC_PER_SEC - 1)
 		};
 
 		return get_jiffies_64() + timespec64_to_jiffies(&ts);