]> git.notmuchmail.org Git - notmuch/blob - test/corpora/lkml/cur/1382298770.001734:2,
test: add 'lkml' corpus
[notmuch] / test / corpora / lkml / cur / 1382298770.001734:2,
1 From: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
2 Subject: [RFC][PATCH 04/10] cifs: define server-level cache index objects and register them with FS-Cache
3 Date: Tue, 22 Jun 2010 20:53:18 +0530
4 Lines: 186
5 Message-ID: <1277220198-3522-1-git-send-email-sjayaraman@suse.de>
6 References: <yes>
7 Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
8         linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
9 To: Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
10 X-From: linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Tue Jun 22 17:44:26 2010
11 Return-path: <linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
12 Envelope-to: glkc-linux-cifs-1dZseelyfdZg9hUCZPvPmw@public.gmane.org
13 Received: from vger.kernel.org ([209.132.180.67])
14         by lo.gmane.org with esmtp (Exim 4.69)
15         (envelope-from <linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>)
16         id 1OR5eD-0008G7-KP
17         for glkc-linux-cifs-1dZseelyfdZg9hUCZPvPmw@public.gmane.org; Tue, 22 Jun 2010 17:44:26 +0200
18 Received: (majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org) by vger.kernel.org via listexpand
19         id S1753942Ab0FVPoC (ORCPT <rfc822;glkc-linux-cifs@m.gmane.org>);
20         Tue, 22 Jun 2010 11:44:02 -0400
21 Received: from victor.provo.novell.com ([137.65.250.26]:58783 "EHLO
22         victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
23         with ESMTP id S1751265Ab0FVPoA (ORCPT
24         <rfc822;groupwise-SJayaraman-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org:0:0>);
25         Tue, 22 Jun 2010 11:44:00 -0400
26 Received: from localhost (prv-ext-foundry1int.gns.novell.com [137.65.251.240])
27         by victor.provo.novell.com with ESMTP; Tue, 22 Jun 2010 09:23:20 -0600
28 X-Mailer: git-send-email 1.6.4.2
29 In-Reply-To: <yes>
30 Sender: linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
31 Precedence: bulk
32 List-ID: <linux-cifs.vger.kernel.org>
33 X-Mailing-List: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
34 Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/1001760>
35
36 Define server-level cache index objects (as managed by TCP_ServerInfo structs).
37 Each server object is created in the CIFS top-level index object and is itself
38 an index into which superblock-level objects are inserted.
39
40 Currently, the server objects are keyed by hostname.
41
42 Signed-off-by: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
43 ---
44  fs/cifs/Makefile   |    2 +-
45  fs/cifs/cache.c    |   25 +++++++++++++++++++++++++
46  fs/cifs/cifsglob.h |    3 +++
47  fs/cifs/connect.c  |    4 ++++
48  fs/cifs/fscache.c  |   47 +++++++++++++++++++++++++++++++++++++++++++++++
49  fs/cifs/fscache.h  |   12 ++++++++++++
50  6 files changed, 92 insertions(+), 1 deletion(-)
51  create mode 100644 fs/cifs/fscache.c
52
53 Index: cifs-2.6/fs/cifs/Makefile
54 ===================================================================
55 --- cifs-2.6.orig/fs/cifs/Makefile
56 +++ cifs-2.6/fs/cifs/Makefile
57 @@ -12,4 +12,4 @@ cifs-$(CONFIG_CIFS_UPCALL) += cifs_spneg
58  
59  cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o
60  
61 -cifs-$(CONFIG_CIFS_FSCACHE) += cache.o
62 +cifs-$(CONFIG_CIFS_FSCACHE) += fscache.o cache.o
63 Index: cifs-2.6/fs/cifs/cache.c
64 ===================================================================
65 --- cifs-2.6.orig/fs/cifs/cache.c
66 +++ cifs-2.6/fs/cifs/cache.c
67 @@ -51,3 +51,28 @@ void cifs_fscache_unregister(void)
68         fscache_unregister_netfs(&cifs_fscache_netfs);
69  }
70  
71 +/*
72 + * Server object currently keyed by hostname
73 + */
74 +static uint16_t cifs_server_get_key(const void *cookie_netfs_data,
75 +                                  void *buffer, uint16_t maxbuf)
76 +{
77 +       const struct TCP_Server_Info *server = cookie_netfs_data;
78 +       uint16_t len = strnlen(server->hostname, sizeof(server->hostname));
79 +
80 +       if (len > maxbuf)
81 +               return 0;
82 +
83 +       memcpy(buffer, server->hostname, len);
84 +
85 +       return len;
86 +}
87 +
88 +/*
89 + * Server object for FS-Cache
90 + */
91 +const struct fscache_cookie_def cifs_fscache_server_index_def = {
92 +       .name = "CIFS.server",
93 +       .type = FSCACHE_COOKIE_TYPE_INDEX,
94 +       .get_key = cifs_server_get_key,
95 +};
96 Index: cifs-2.6/fs/cifs/cifsglob.h
97 ===================================================================
98 --- cifs-2.6.orig/fs/cifs/cifsglob.h
99 +++ cifs-2.6/fs/cifs/cifsglob.h
100 @@ -193,6 +193,9 @@ struct TCP_Server_Info {
101         bool    sec_mskerberos;         /* supports legacy MS Kerberos */
102         bool    sec_kerberosu2u;        /* supports U2U Kerberos */
103         bool    sec_ntlmssp;            /* supports NTLMSSP */
104 +#ifdef CONFIG_CIFS_FSCACHE
105 +       struct fscache_cookie   *fscache; /* client index cache cookie */
106 +#endif
107  };
108  
109  /*
110 Index: cifs-2.6/fs/cifs/connect.c
111 ===================================================================
112 --- cifs-2.6.orig/fs/cifs/connect.c
113 +++ cifs-2.6/fs/cifs/connect.c
114 @@ -48,6 +48,7 @@
115  #include "nterr.h"
116  #include "rfc1002pdu.h"
117  #include "cn_cifs.h"
118 +#include "fscache.h"
119  
120  #define CIFS_PORT 445
121  #define RFC1001_PORT 139
122 @@ -1453,6 +1454,8 @@ cifs_put_tcp_session(struct TCP_Server_I
123                 return;
124         }
125  
126 +       cifs_fscache_release_client_cookie(server);
127 +
128         list_del_init(&server->tcp_ses_list);
129         write_unlock(&cifs_tcp_ses_lock);
130  
131 @@ -1572,6 +1575,7 @@ cifs_get_tcp_session(struct smb_vol *vol
132                 goto out_err;
133         }
134  
135 +       cifs_fscache_get_client_cookie(tcp_ses);
136         /* thread spawned, put it on the list */
137         write_lock(&cifs_tcp_ses_lock);
138         list_add(&tcp_ses->tcp_ses_list, &cifs_tcp_ses_list);
139 Index: cifs-2.6/fs/cifs/fscache.c
140 ===================================================================
141 --- /dev/null
142 +++ cifs-2.6/fs/cifs/fscache.c
143 @@ -0,0 +1,47 @@
144 +/*
145 + *   fs/cifs/fscache.c - CIFS filesystem cache interface
146 + *
147 + *   Copyright (c) 2010 Novell, Inc.
148 + *   Authors(s): Suresh Jayaraman (sjayaraman-l3A5Bk7waGM@public.gmane.org>
149 + *
150 + *   This library is free software; you can redistribute it and/or modify
151 + *   it under the terms of the GNU Lesser General Public License as published
152 + *   by the Free Software Foundation; either version 2.1 of the License, or
153 + *   (at your option) any later version.
154 + *
155 + *   This library is distributed in the hope that it will be useful,
156 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of
157 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
158 + *   the GNU Lesser General Public License for more details.
159 + *
160 + *   You should have received a copy of the GNU Lesser General Public License
161 + *   along with this library; if not, write to the Free Software
162 + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
163 + */
164 +#include <linux/init.h>
165 +#include <linux/kernel.h>
166 +#include <linux/sched.h>
167 +#include <linux/mm.h>
168 +#include <linux/in6.h>
169 +
170 +#include "fscache.h"
171 +#include "cifsglob.h"
172 +#include "cifs_debug.h"
173 +
174 +void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server)
175 +{
176 +       server->fscache =
177 +               fscache_acquire_cookie(cifs_fscache_netfs.primary_index,
178 +                               &cifs_fscache_server_index_def, server);
179 +       cFYI(1, "CIFS: get client cookie (0x%p/0x%p)\n",
180 +                               server, server->fscache);
181 +}
182 +
183 +void cifs_fscache_release_client_cookie(struct TCP_Server_Info *server)
184 +{
185 +       cFYI(1, "CIFS: release client cookie (0x%p/0x%p)\n",
186 +                               server, server->fscache);
187 +       fscache_relinquish_cookie(server->fscache, 0);
188 +       server->fscache = NULL;
189 +}
190 +
191 Index: cifs-2.6/fs/cifs/fscache.h
192 ===================================================================
193 --- cifs-2.6.orig/fs/cifs/fscache.h
194 +++ cifs-2.6/fs/cifs/fscache.h
195 @@ -27,14 +27,26 @@
196  #ifdef CONFIG_CIFS_FSCACHE
197  
198  extern struct fscache_netfs cifs_fscache_netfs;
199 +extern const struct fscache_cookie_def cifs_fscache_server_index_def;
200  
201  extern int cifs_fscache_register(void);
202  extern void cifs_fscache_unregister(void);
203  
204 +/*
205 + * fscache.c
206 + */
207 +extern void cifs_fscache_get_client_cookie(struct TCP_Server_Info *);
208 +extern void cifs_fscache_release_client_cookie(struct TCP_Server_Info *);
209 +
210  #else /* CONFIG_CIFS_FSCACHE */
211  static inline int cifs_fscache_register(void) { return 0; }
212  static inline void cifs_fscache_unregister(void) {}
213  
214 +static inline void
215 +cifs_fscache_get_client_cookie(struct TCP_Server_Info *server) {}
216 +static inline void
217 +cifs_fscache_get_client_cookie(struct TCP_Server_Info *server); {}
218 +
219  #endif /* CONFIG_CIFS_FSCACHE */
220  
221  #endif /* _CIFS_FSCACHE_H */
222
223