From patchwork Tue Nov 16 10:09:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suresh Jayaraman X-Patchwork-Id: 327352 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAGA9vGl012147 for ; Tue, 16 Nov 2010 10:09:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932532Ab0KPKJ4 (ORCPT ); Tue, 16 Nov 2010 05:09:56 -0500 Received: from victor.provo.novell.com ([137.65.250.26]:43098 "EHLO victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932529Ab0KPKJ4 (ORCPT ); Tue, 16 Nov 2010 05:09:56 -0500 Received: from localhost (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by victor.provo.novell.com with ESMTP; Tue, 16 Nov 2010 03:09:40 -0700 From: Suresh Jayaraman To: Steve French Cc: linux-cifs@vger.kernel.org Subject: [RFC][PATCH] cifs: add attribute cache timeout (actimeo) tunable Date: Tue, 16 Nov 2010 15:39:37 +0530 Message-Id: <1289902177-12963-1-git-send-email-sjayaraman@suse.de> X-Mailer: git-send-email 1.7.1 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 16 Nov 2010 10:09:57 +0000 (UTC) diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h index e9a393c..efd2d73 100644 --- a/fs/cifs/cifs_fs_sb.h +++ b/fs/cifs/cifs_fs_sb.h @@ -48,6 +48,7 @@ struct cifs_sb_info { struct nls_table *local_nls; unsigned int rsize; unsigned int wsize; + unsigned int actimeo; atomic_t active; uid_t mnt_uid; gid_t mnt_gid; diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index b577bf0..eb22130 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -44,6 +44,9 @@ #define CIFS_MIN_RCV_POOL 4 +#define CIFS_DEF_ACTIMEO (3) /* default attribute cache timeout (seconds) */ +#define CIFS_MAX_ACTIMEO (60) /* max allowed attribute cache timeout */ + /* * MAX_REQ is the maximum number of requests that WE will send * on one socket concurrently. It also matches the most common diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 251a17c..39edc54 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -103,6 +103,7 @@ struct smb_vol { bool multiuser:1; unsigned int rsize; unsigned int wsize; + unsigned int actimeo; /* attribute cache timeout */ bool sockopt_tcp_nodelay:1; unsigned short int port; char *prepath; @@ -1214,6 +1215,10 @@ cifs_parse_mount_options(char *options, const char *devname, printk(KERN_WARNING "CIFS: server net" "biosname longer than 15 truncated.\n"); } + } else if (strnicmp(data, "actimeo", 7) == 0) { + if (value && *value) + vol->actimeo = + simple_strtoul(value, &value, 0); } else if (strnicmp(data, "credentials", 4) == 0) { /* ignore */ } else if (strnicmp(data, "version", 3) == 0) { @@ -2566,6 +2571,17 @@ static void setup_cifs_sb(struct smb_vol *pvolume_info, cFYI(1, "file mode: 0x%x dir mode: 0x%x", cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode); + if ((pvolume_info->actimeo) && + (pvolume_info->actimeo < CIFS_MAX_ACTIMEO)) + cifs_sb->actimeo = pvolume_info->actimeo; + else if ((pvolume_info->actimeo) && + (pvolume_info->actimeo >= CIFS_MAX_ACTIMEO)) { + cifs_sb->actimeo = CIFS_MAX_ACTIMEO; + cERROR(1, "actimeo %d too large, using %d instead", + pvolume_info->actimeo, CIFS_MAX_ACTIMEO); + } else /* default */ + cifs_sb->actimeo = CIFS_DEF_ACTIMEO; + if (pvolume_info->noperm) cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; if (pvolume_info->setuids) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index ff7d299..f30700d 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -1648,6 +1648,7 @@ static bool cifs_inode_needs_reval(struct inode *inode) { struct cifsInodeInfo *cifs_i = CIFS_I(inode); + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); if (cifs_i->clientCanCacheRead) return false; @@ -1658,12 +1659,11 @@ cifs_inode_needs_reval(struct inode *inode) if (cifs_i->time == 0) return true; - /* FIXME: the actimeo should be tunable */ - if (time_after_eq(jiffies, cifs_i->time + HZ)) + if (time_after_eq(jiffies, cifs_i->time + (cifs_sb->actimeo * HZ))) return true; /* hardlinked files w/ noserverino get "special" treatment */ - if (!(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) && + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) && S_ISREG(inode->i_mode) && inode->i_nlink != 1) return true;