aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-14 12:10:34 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-05-10 22:18:18 -0400
commitb46c267e4756a88593c4a08de869e70d3907637f (patch)
treea762a6bff792f443003845e0e70cf609a97a55f8 /fs/9p
parent030bbdbf4c833bc69f502eae58498bc5572db736 (diff)
9p: don't bother with 4K allocation for 24-byte local array...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/vfs_inode.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 703342e309f5..cda68f70d757 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1370,6 +1370,8 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1370 return v9fs_vfs_mkspecial(dir, dentry, P9_DMSYMLINK, symname); 1370 return v9fs_vfs_mkspecial(dir, dentry, P9_DMSYMLINK, symname);
1371} 1371}
1372 1372
1373#define U32_MAX_DIGITS 10
1374
1373/** 1375/**
1374 * v9fs_vfs_link - create a hardlink 1376 * v9fs_vfs_link - create a hardlink
1375 * @old_dentry: dentry for file to link to 1377 * @old_dentry: dentry for file to link to
@@ -1383,7 +1385,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1383 struct dentry *dentry) 1385 struct dentry *dentry)
1384{ 1386{
1385 int retval; 1387 int retval;
1386 char *name; 1388 char name[1 + U32_MAX_DIGITS + 2]; /* sign + number + \n + \0 */
1387 struct p9_fid *oldfid; 1389 struct p9_fid *oldfid;
1388 1390
1389 p9_debug(P9_DEBUG_VFS, " %lu,%pd,%pd\n", 1391 p9_debug(P9_DEBUG_VFS, " %lu,%pd,%pd\n",
@@ -1393,20 +1395,12 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1393 if (IS_ERR(oldfid)) 1395 if (IS_ERR(oldfid))
1394 return PTR_ERR(oldfid); 1396 return PTR_ERR(oldfid);
1395 1397
1396 name = __getname();
1397 if (unlikely(!name)) {
1398 retval = -ENOMEM;
1399 goto clunk_fid;
1400 }
1401
1402 sprintf(name, "%d\n", oldfid->fid); 1398 sprintf(name, "%d\n", oldfid->fid);
1403 retval = v9fs_vfs_mkspecial(dir, dentry, P9_DMLINK, name); 1399 retval = v9fs_vfs_mkspecial(dir, dentry, P9_DMLINK, name);
1404 __putname(name);
1405 if (!retval) { 1400 if (!retval) {
1406 v9fs_refresh_inode(oldfid, d_inode(old_dentry)); 1401 v9fs_refresh_inode(oldfid, d_inode(old_dentry));
1407 v9fs_invalidate_inode_attr(dir); 1402 v9fs_invalidate_inode_attr(dir);
1408 } 1403 }
1409clunk_fid:
1410 p9_client_clunk(oldfid); 1404 p9_client_clunk(oldfid);
1411 return retval; 1405 return retval;
1412} 1406}
@@ -1425,7 +1419,7 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rde
1425{ 1419{
1426 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); 1420 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
1427 int retval; 1421 int retval;
1428 char *name; 1422 char name[2 + U32_MAX_DIGITS + 1 + U32_MAX_DIGITS + 1];
1429 u32 perm; 1423 u32 perm;
1430 1424
1431 p9_debug(P9_DEBUG_VFS, " %lu,%pd mode: %hx MAJOR: %u MINOR: %u\n", 1425 p9_debug(P9_DEBUG_VFS, " %lu,%pd mode: %hx MAJOR: %u MINOR: %u\n",
@@ -1435,26 +1429,16 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rde
1435 if (!new_valid_dev(rdev)) 1429 if (!new_valid_dev(rdev))
1436 return -EINVAL; 1430 return -EINVAL;
1437 1431
1438 name = __getname();
1439 if (!name)
1440 return -ENOMEM;
1441 /* build extension */ 1432 /* build extension */
1442 if (S_ISBLK(mode)) 1433 if (S_ISBLK(mode))
1443 sprintf(name, "b %u %u", MAJOR(rdev), MINOR(rdev)); 1434 sprintf(name, "b %u %u", MAJOR(rdev), MINOR(rdev));
1444 else if (S_ISCHR(mode)) 1435 else if (S_ISCHR(mode))
1445 sprintf(name, "c %u %u", MAJOR(rdev), MINOR(rdev)); 1436 sprintf(name, "c %u %u", MAJOR(rdev), MINOR(rdev));
1446 else if (S_ISFIFO(mode)) 1437 else
1447 *name = 0;
1448 else if (S_ISSOCK(mode))
1449 *name = 0; 1438 *name = 0;
1450 else {
1451 __putname(name);
1452 return -EINVAL;
1453 }
1454 1439
1455 perm = unixmode2p9mode(v9ses, mode); 1440 perm = unixmode2p9mode(v9ses, mode);
1456 retval = v9fs_vfs_mkspecial(dir, dentry, perm, name); 1441 retval = v9fs_vfs_mkspecial(dir, dentry, perm, name);
1457 __putname(name);
1458 1442
1459 return retval; 1443 return retval;
1460} 1444}