Commit 7c9e592e1f6a994d2903c9b055e488ec90f58159

Authored by Aneesh Kumar K.V
Committed by Eric Van Hensbergen
1 parent 3dc5436aa5

fs/9p: Make the writeback_fid owned by root

Changes to make sure writeback fid is owned by root

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>

Showing 1 changed file with 56 additions and 36 deletions Side-by-side Diff

... ... @@ -125,46 +125,17 @@
125 125 return -ENOMEM;
126 126 }
127 127  
128   -/**
129   - * v9fs_fid_lookup - lookup for a fid, try to walk if not found
130   - * @dentry: dentry to look for fid in
131   - *
132   - * Look for a fid in the specified dentry for the current user.
133   - * If no fid is found, try to create one walking from a fid from the parent
134   - * dentry (if it has one), or the root dentry. If the user haven't accessed
135   - * the fs yet, attach now and walk from the root.
136   - */
137   -
138   -struct p9_fid *v9fs_fid_lookup(struct dentry *dentry)
  128 +static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
  129 + uid_t uid, int any)
139 130 {
140   - int i, n, l, clone, any, access;
141   - u32 uid;
142   - struct p9_fid *fid, *old_fid = NULL;
143 131 struct dentry *ds;
144   - struct v9fs_session_info *v9ses;
145 132 char **wnames, *uname;
  133 + int i, n, l, clone, access;
  134 + struct v9fs_session_info *v9ses;
  135 + struct p9_fid *fid, *old_fid = NULL;
146 136  
147 137 v9ses = v9fs_inode2v9ses(dentry->d_inode);
148 138 access = v9ses->flags & V9FS_ACCESS_MASK;
149   - switch (access) {
150   - case V9FS_ACCESS_SINGLE:
151   - case V9FS_ACCESS_USER:
152   - case V9FS_ACCESS_CLIENT:
153   - uid = current_fsuid();
154   - any = 0;
155   - break;
156   -
157   - case V9FS_ACCESS_ANY:
158   - uid = v9ses->uid;
159   - any = 1;
160   - break;
161   -
162   - default:
163   - uid = ~0;
164   - any = 0;
165   - break;
166   - }
167   -
168 139 fid = v9fs_fid_find(dentry, uid, any);
169 140 if (fid)
170 141 return fid;
... ... @@ -250,6 +221,45 @@
250 221 return fid;
251 222 }
252 223  
  224 +/**
  225 + * v9fs_fid_lookup - lookup for a fid, try to walk if not found
  226 + * @dentry: dentry to look for fid in
  227 + *
  228 + * Look for a fid in the specified dentry for the current user.
  229 + * If no fid is found, try to create one walking from a fid from the parent
  230 + * dentry (if it has one), or the root dentry. If the user haven't accessed
  231 + * the fs yet, attach now and walk from the root.
  232 + */
  233 +
  234 +struct p9_fid *v9fs_fid_lookup(struct dentry *dentry)
  235 +{
  236 + uid_t uid;
  237 + int any, access;
  238 + struct v9fs_session_info *v9ses;
  239 +
  240 + v9ses = v9fs_inode2v9ses(dentry->d_inode);
  241 + access = v9ses->flags & V9FS_ACCESS_MASK;
  242 + switch (access) {
  243 + case V9FS_ACCESS_SINGLE:
  244 + case V9FS_ACCESS_USER:
  245 + case V9FS_ACCESS_CLIENT:
  246 + uid = current_fsuid();
  247 + any = 0;
  248 + break;
  249 +
  250 + case V9FS_ACCESS_ANY:
  251 + uid = v9ses->uid;
  252 + any = 1;
  253 + break;
  254 +
  255 + default:
  256 + uid = ~0;
  257 + any = 0;
  258 + break;
  259 + }
  260 + return v9fs_fid_lookup_with_uid(dentry, uid, any);
  261 +}
  262 +
253 263 struct p9_fid *v9fs_fid_clone(struct dentry *dentry)
254 264 {
255 265 struct p9_fid *fid, *ret;
256 266  
257 267  
... ... @@ -262,13 +272,24 @@
262 272 return ret;
263 273 }
264 274  
  275 +static struct p9_fid *v9fs_fid_clone_with_uid(struct dentry *dentry, uid_t uid)
  276 +{
  277 + struct p9_fid *fid, *ret;
265 278  
  279 + fid = v9fs_fid_lookup_with_uid(dentry, uid, 0);
  280 + if (IS_ERR(fid))
  281 + return fid;
  282 +
  283 + ret = p9_client_walk(fid, 0, NULL, 1);
  284 + return ret;
  285 +}
  286 +
266 287 struct p9_fid *v9fs_writeback_fid(struct dentry *dentry)
267 288 {
268 289 int err;
269 290 struct p9_fid *fid;
270 291  
271   - fid = v9fs_fid_clone(dentry);
  292 + fid = v9fs_fid_clone_with_uid(dentry, 0);
272 293 if (IS_ERR(fid))
273 294 goto error_out;
274 295 /*
... ... @@ -276,7 +297,6 @@
276 297 * dirty pages. We always request for the open fid in read-write
277 298 * mode so that a partial page write which result in page
278 299 * read can work.
279   - * FIXME!!: we should make the fid owned by uid = 0
280 300 */
281 301 err = p9_client_open(fid, O_RDWR);
282 302 if (err < 0) {