diff options
Diffstat (limited to 'fs/ufs/super.c')
-rw-r--r-- | fs/ufs/super.c | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 2b08a8dd8ec0..3c9bbf23c2ff 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -77,7 +77,6 @@ | |||
77 | 77 | ||
78 | #include <linux/errno.h> | 78 | #include <linux/errno.h> |
79 | #include <linux/fs.h> | 79 | #include <linux/fs.h> |
80 | #include <linux/quotaops.h> | ||
81 | #include <linux/slab.h> | 80 | #include <linux/slab.h> |
82 | #include <linux/time.h> | 81 | #include <linux/time.h> |
83 | #include <linux/stat.h> | 82 | #include <linux/stat.h> |
@@ -1045,10 +1044,6 @@ magic_found: | |||
1045 | */ | 1044 | */ |
1046 | sb->s_op = &ufs_super_ops; | 1045 | sb->s_op = &ufs_super_ops; |
1047 | sb->s_export_op = &ufs_export_ops; | 1046 | sb->s_export_op = &ufs_export_ops; |
1048 | #ifdef CONFIG_QUOTA | ||
1049 | sb->s_qcop = &dquot_quotactl_ops; | ||
1050 | sb->dq_op = NULL; /* &dquot_operations */ | ||
1051 | #endif | ||
1052 | 1047 | ||
1053 | sb->s_magic = fs32_to_cpu(sb, usb3->fs_magic); | 1048 | sb->s_magic = fs32_to_cpu(sb, usb3->fs_magic); |
1054 | 1049 | ||
@@ -1231,8 +1226,6 @@ static void ufs_put_super(struct super_block *sb) | |||
1231 | 1226 | ||
1232 | UFSD("ENTER\n"); | 1227 | UFSD("ENTER\n"); |
1233 | 1228 | ||
1234 | dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); | ||
1235 | |||
1236 | if (sb->s_dirt) | 1229 | if (sb->s_dirt) |
1237 | ufs_write_super(sb); | 1230 | ufs_write_super(sb); |
1238 | 1231 | ||
@@ -1254,9 +1247,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1254 | struct ufs_super_block_first * usb1; | 1247 | struct ufs_super_block_first * usb1; |
1255 | struct ufs_super_block_third * usb3; | 1248 | struct ufs_super_block_third * usb3; |
1256 | unsigned new_mount_opt, ufstype; | 1249 | unsigned new_mount_opt, ufstype; |
1257 | int enable_quota = 0; | ||
1258 | unsigned flags; | 1250 | unsigned flags; |
1259 | int err; | ||
1260 | 1251 | ||
1261 | lock_kernel(); | 1252 | lock_kernel(); |
1262 | lock_super(sb); | 1253 | lock_super(sb); |
@@ -1297,13 +1288,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1297 | * fs was mouted as rw, remounting ro | 1288 | * fs was mouted as rw, remounting ro |
1298 | */ | 1289 | */ |
1299 | if (*mount_flags & MS_RDONLY) { | 1290 | if (*mount_flags & MS_RDONLY) { |
1300 | err = dquot_suspend(sb, -1); | ||
1301 | if (err < 0) { | ||
1302 | unlock_super(sb); | ||
1303 | unlock_kernel(); | ||
1304 | return err; | ||
1305 | } | ||
1306 | |||
1307 | ufs_put_super_internal(sb); | 1291 | ufs_put_super_internal(sb); |
1308 | usb1->fs_time = cpu_to_fs32(sb, get_seconds()); | 1292 | usb1->fs_time = cpu_to_fs32(sb, get_seconds()); |
1309 | if ((flags & UFS_ST_MASK) == UFS_ST_SUN | 1293 | if ((flags & UFS_ST_MASK) == UFS_ST_SUN |
@@ -1342,14 +1326,11 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1342 | return -EPERM; | 1326 | return -EPERM; |
1343 | } | 1327 | } |
1344 | sb->s_flags &= ~MS_RDONLY; | 1328 | sb->s_flags &= ~MS_RDONLY; |
1345 | enable_quota = 1; | ||
1346 | #endif | 1329 | #endif |
1347 | } | 1330 | } |
1348 | UFS_SB(sb)->s_mount_opt = new_mount_opt; | 1331 | UFS_SB(sb)->s_mount_opt = new_mount_opt; |
1349 | unlock_super(sb); | 1332 | unlock_super(sb); |
1350 | unlock_kernel(); | 1333 | unlock_kernel(); |
1351 | if (enable_quota) | ||
1352 | dquot_resume(sb, -1); | ||
1353 | return 0; | 1334 | return 0; |
1354 | } | 1335 | } |
1355 | 1336 | ||
@@ -1453,126 +1434,19 @@ static void destroy_inodecache(void) | |||
1453 | kmem_cache_destroy(ufs_inode_cachep); | 1434 | kmem_cache_destroy(ufs_inode_cachep); |
1454 | } | 1435 | } |
1455 | 1436 | ||
1456 | static void ufs_clear_inode(struct inode *inode) | ||
1457 | { | ||
1458 | dquot_drop(inode); | ||
1459 | } | ||
1460 | |||
1461 | #ifdef CONFIG_QUOTA | ||
1462 | static ssize_t ufs_quota_read(struct super_block *, int, char *,size_t, loff_t); | ||
1463 | static ssize_t ufs_quota_write(struct super_block *, int, const char *, size_t, loff_t); | ||
1464 | #endif | ||
1465 | |||
1466 | static const struct super_operations ufs_super_ops = { | 1437 | static const struct super_operations ufs_super_ops = { |
1467 | .alloc_inode = ufs_alloc_inode, | 1438 | .alloc_inode = ufs_alloc_inode, |
1468 | .destroy_inode = ufs_destroy_inode, | 1439 | .destroy_inode = ufs_destroy_inode, |
1469 | .write_inode = ufs_write_inode, | 1440 | .write_inode = ufs_write_inode, |
1470 | .delete_inode = ufs_delete_inode, | 1441 | .delete_inode = ufs_delete_inode, |
1471 | .clear_inode = ufs_clear_inode, | ||
1472 | .put_super = ufs_put_super, | 1442 | .put_super = ufs_put_super, |
1473 | .write_super = ufs_write_super, | 1443 | .write_super = ufs_write_super, |
1474 | .sync_fs = ufs_sync_fs, | 1444 | .sync_fs = ufs_sync_fs, |
1475 | .statfs = ufs_statfs, | 1445 | .statfs = ufs_statfs, |
1476 | .remount_fs = ufs_remount, | 1446 | .remount_fs = ufs_remount, |
1477 | .show_options = ufs_show_options, | 1447 | .show_options = ufs_show_options, |
1478 | #ifdef CONFIG_QUOTA | ||
1479 | .quota_read = ufs_quota_read, | ||
1480 | .quota_write = ufs_quota_write, | ||
1481 | #endif | ||
1482 | }; | 1448 | }; |
1483 | 1449 | ||
1484 | #ifdef CONFIG_QUOTA | ||
1485 | |||
1486 | /* Read data from quotafile - avoid pagecache and such because we cannot afford | ||
1487 | * acquiring the locks... As quota files are never truncated and quota code | ||
1488 | * itself serializes the operations (and noone else should touch the files) | ||
1489 | * we don't have to be afraid of races */ | ||
1490 | static ssize_t ufs_quota_read(struct super_block *sb, int type, char *data, | ||
1491 | size_t len, loff_t off) | ||
1492 | { | ||
1493 | struct inode *inode = sb_dqopt(sb)->files[type]; | ||
1494 | sector_t blk = off >> sb->s_blocksize_bits; | ||
1495 | int err = 0; | ||
1496 | int offset = off & (sb->s_blocksize - 1); | ||
1497 | int tocopy; | ||
1498 | size_t toread; | ||
1499 | struct buffer_head *bh; | ||
1500 | loff_t i_size = i_size_read(inode); | ||
1501 | |||
1502 | if (off > i_size) | ||
1503 | return 0; | ||
1504 | if (off+len > i_size) | ||
1505 | len = i_size-off; | ||
1506 | toread = len; | ||
1507 | while (toread > 0) { | ||
1508 | tocopy = sb->s_blocksize - offset < toread ? | ||
1509 | sb->s_blocksize - offset : toread; | ||
1510 | |||
1511 | bh = ufs_bread(inode, blk, 0, &err); | ||
1512 | if (err) | ||
1513 | return err; | ||
1514 | if (!bh) /* A hole? */ | ||
1515 | memset(data, 0, tocopy); | ||
1516 | else { | ||
1517 | memcpy(data, bh->b_data+offset, tocopy); | ||
1518 | brelse(bh); | ||
1519 | } | ||
1520 | offset = 0; | ||
1521 | toread -= tocopy; | ||
1522 | data += tocopy; | ||
1523 | blk++; | ||
1524 | } | ||
1525 | return len; | ||
1526 | } | ||
1527 | |||
1528 | /* Write to quotafile */ | ||
1529 | static ssize_t ufs_quota_write(struct super_block *sb, int type, | ||
1530 | const char *data, size_t len, loff_t off) | ||
1531 | { | ||
1532 | struct inode *inode = sb_dqopt(sb)->files[type]; | ||
1533 | sector_t blk = off >> sb->s_blocksize_bits; | ||
1534 | int err = 0; | ||
1535 | int offset = off & (sb->s_blocksize - 1); | ||
1536 | int tocopy; | ||
1537 | size_t towrite = len; | ||
1538 | struct buffer_head *bh; | ||
1539 | |||
1540 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); | ||
1541 | while (towrite > 0) { | ||
1542 | tocopy = sb->s_blocksize - offset < towrite ? | ||
1543 | sb->s_blocksize - offset : towrite; | ||
1544 | |||
1545 | bh = ufs_bread(inode, blk, 1, &err); | ||
1546 | if (!bh) | ||
1547 | goto out; | ||
1548 | lock_buffer(bh); | ||
1549 | memcpy(bh->b_data+offset, data, tocopy); | ||
1550 | flush_dcache_page(bh->b_page); | ||
1551 | set_buffer_uptodate(bh); | ||
1552 | mark_buffer_dirty(bh); | ||
1553 | unlock_buffer(bh); | ||
1554 | brelse(bh); | ||
1555 | offset = 0; | ||
1556 | towrite -= tocopy; | ||
1557 | data += tocopy; | ||
1558 | blk++; | ||
1559 | } | ||
1560 | out: | ||
1561 | if (len == towrite) { | ||
1562 | mutex_unlock(&inode->i_mutex); | ||
1563 | return err; | ||
1564 | } | ||
1565 | if (inode->i_size < off+len-towrite) | ||
1566 | i_size_write(inode, off+len-towrite); | ||
1567 | inode->i_version++; | ||
1568 | inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; | ||
1569 | mark_inode_dirty(inode); | ||
1570 | mutex_unlock(&inode->i_mutex); | ||
1571 | return len - towrite; | ||
1572 | } | ||
1573 | |||
1574 | #endif | ||
1575 | |||
1576 | static int ufs_get_sb(struct file_system_type *fs_type, | 1450 | static int ufs_get_sb(struct file_system_type *fs_type, |
1577 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) | 1451 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) |
1578 | { | 1452 | { |