quota.c (0c49cd295d42d0032af11d55e2140dbec11dc8d0) | quota.c (14bf61ffe6ac54afcd1e888a4407fe16054483db) |
---|---|
1/* 2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. 4 * 5 * This copyrighted material is made available to anyone wishing to use, 6 * modify, copy, or redistribute it subject to the terms and conditions 7 * of the GNU General Public License version 2. 8 */ --- 653 unchanged lines hidden (view full) --- 662 * This function was mostly borrowed from gfs2_block_truncate_page which was 663 * in turn mostly borrowed from ext3 664 * 665 * Returns: 0 or -ve on error 666 */ 667 668static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, 669 s64 change, struct gfs2_quota_data *qd, | 1/* 2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. 4 * 5 * This copyrighted material is made available to anyone wishing to use, 6 * modify, copy, or redistribute it subject to the terms and conditions 7 * of the GNU General Public License version 2. 8 */ --- 653 unchanged lines hidden (view full) --- 662 * This function was mostly borrowed from gfs2_block_truncate_page which was 663 * in turn mostly borrowed from ext3 664 * 665 * Returns: 0 or -ve on error 666 */ 667 668static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, 669 s64 change, struct gfs2_quota_data *qd, |
670 struct fs_disk_quota *fdq) | 670 struct qc_dqblk *fdq) |
671{ 672 struct inode *inode = &ip->i_inode; 673 struct gfs2_sbd *sdp = GFS2_SB(inode); 674 struct address_space *mapping = inode->i_mapping; 675 unsigned long index = loc >> PAGE_CACHE_SHIFT; 676 unsigned offset = loc & (PAGE_CACHE_SIZE - 1); 677 unsigned blocksize, iblock, pos; 678 struct buffer_head *bh; --- 13 unchanged lines hidden (view full) --- 692 err = gfs2_internal_read(ip, (char *)&q, &loc, sizeof(q)); 693 if (err < 0) 694 return err; 695 696 err = -EIO; 697 be64_add_cpu(&q.qu_value, change); 698 qd->qd_qb.qb_value = q.qu_value; 699 if (fdq) { | 671{ 672 struct inode *inode = &ip->i_inode; 673 struct gfs2_sbd *sdp = GFS2_SB(inode); 674 struct address_space *mapping = inode->i_mapping; 675 unsigned long index = loc >> PAGE_CACHE_SHIFT; 676 unsigned offset = loc & (PAGE_CACHE_SIZE - 1); 677 unsigned blocksize, iblock, pos; 678 struct buffer_head *bh; --- 13 unchanged lines hidden (view full) --- 692 err = gfs2_internal_read(ip, (char *)&q, &loc, sizeof(q)); 693 if (err < 0) 694 return err; 695 696 err = -EIO; 697 be64_add_cpu(&q.qu_value, change); 698 qd->qd_qb.qb_value = q.qu_value; 699 if (fdq) { |
700 if (fdq->d_fieldmask & FS_DQ_BSOFT) { 701 q.qu_warn = cpu_to_be64(fdq->d_blk_softlimit >> sdp->sd_fsb2bb_shift); | 700 if (fdq->d_fieldmask & QC_SPC_SOFT) { 701 q.qu_warn = cpu_to_be64(fdq->d_spc_softlimit >> sdp->sd_sb.sb_bsize_shift); |
702 qd->qd_qb.qb_warn = q.qu_warn; 703 } | 702 qd->qd_qb.qb_warn = q.qu_warn; 703 } |
704 if (fdq->d_fieldmask & FS_DQ_BHARD) { 705 q.qu_limit = cpu_to_be64(fdq->d_blk_hardlimit >> sdp->sd_fsb2bb_shift); | 704 if (fdq->d_fieldmask & QC_SPC_HARD) { 705 q.qu_limit = cpu_to_be64(fdq->d_spc_hardlimit >> sdp->sd_sb.sb_bsize_shift); |
706 qd->qd_qb.qb_limit = q.qu_limit; 707 } | 706 qd->qd_qb.qb_limit = q.qu_limit; 707 } |
708 if (fdq->d_fieldmask & FS_DQ_BCOUNT) { 709 q.qu_value = cpu_to_be64(fdq->d_bcount >> sdp->sd_fsb2bb_shift); | 708 if (fdq->d_fieldmask & QC_SPACE) { 709 q.qu_value = cpu_to_be64(fdq->d_space >> sdp->sd_sb.sb_bsize_shift); |
710 qd->qd_qb.qb_value = q.qu_value; 711 } 712 } 713 714 /* Write the quota into the quota file on disk */ 715 ptr = &q; 716 nbytes = sizeof(struct gfs2_quota); 717get_a_page: --- 774 unchanged lines hidden (view full) --- 1492 } 1493 fqs->qs_uquota.qfs_nextents = 1; /* unsupported */ 1494 fqs->qs_gquota = fqs->qs_uquota; /* its the same inode in both cases */ 1495 fqs->qs_incoredqs = list_lru_count(&gfs2_qd_lru); 1496 return 0; 1497} 1498 1499static int gfs2_get_dqblk(struct super_block *sb, struct kqid qid, | 710 qd->qd_qb.qb_value = q.qu_value; 711 } 712 } 713 714 /* Write the quota into the quota file on disk */ 715 ptr = &q; 716 nbytes = sizeof(struct gfs2_quota); 717get_a_page: --- 774 unchanged lines hidden (view full) --- 1492 } 1493 fqs->qs_uquota.qfs_nextents = 1; /* unsupported */ 1494 fqs->qs_gquota = fqs->qs_uquota; /* its the same inode in both cases */ 1495 fqs->qs_incoredqs = list_lru_count(&gfs2_qd_lru); 1496 return 0; 1497} 1498 1499static int gfs2_get_dqblk(struct super_block *sb, struct kqid qid, |
1500 struct fs_disk_quota *fdq) | 1500 struct qc_dqblk *fdq) |
1501{ 1502 struct gfs2_sbd *sdp = sb->s_fs_info; 1503 struct gfs2_quota_lvb *qlvb; 1504 struct gfs2_quota_data *qd; 1505 struct gfs2_holder q_gh; 1506 int error; 1507 | 1501{ 1502 struct gfs2_sbd *sdp = sb->s_fs_info; 1503 struct gfs2_quota_lvb *qlvb; 1504 struct gfs2_quota_data *qd; 1505 struct gfs2_holder q_gh; 1506 int error; 1507 |
1508 memset(fdq, 0, sizeof(struct fs_disk_quota)); | 1508 memset(fdq, 0, sizeof(*fdq)); |
1509 1510 if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF) 1511 return -ESRCH; /* Crazy XFS error code */ 1512 1513 if ((qid.type != USRQUOTA) && 1514 (qid.type != GRPQUOTA)) 1515 return -EINVAL; 1516 1517 error = qd_get(sdp, qid, &qd); 1518 if (error) 1519 return error; 1520 error = do_glock(qd, FORCE, &q_gh); 1521 if (error) 1522 goto out; 1523 1524 qlvb = (struct gfs2_quota_lvb *)qd->qd_gl->gl_lksb.sb_lvbptr; | 1509 1510 if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF) 1511 return -ESRCH; /* Crazy XFS error code */ 1512 1513 if ((qid.type != USRQUOTA) && 1514 (qid.type != GRPQUOTA)) 1515 return -EINVAL; 1516 1517 error = qd_get(sdp, qid, &qd); 1518 if (error) 1519 return error; 1520 error = do_glock(qd, FORCE, &q_gh); 1521 if (error) 1522 goto out; 1523 1524 qlvb = (struct gfs2_quota_lvb *)qd->qd_gl->gl_lksb.sb_lvbptr; |
1525 fdq->d_version = FS_DQUOT_VERSION; 1526 fdq->d_flags = (qid.type == USRQUOTA) ? FS_USER_QUOTA : FS_GROUP_QUOTA; 1527 fdq->d_id = from_kqid_munged(current_user_ns(), qid); 1528 fdq->d_blk_hardlimit = be64_to_cpu(qlvb->qb_limit) << sdp->sd_fsb2bb_shift; 1529 fdq->d_blk_softlimit = be64_to_cpu(qlvb->qb_warn) << sdp->sd_fsb2bb_shift; 1530 fdq->d_bcount = be64_to_cpu(qlvb->qb_value) << sdp->sd_fsb2bb_shift; | 1525 fdq->d_spc_hardlimit = be64_to_cpu(qlvb->qb_limit) << sdp->sd_sb.sb_bsize_shift; 1526 fdq->d_spc_softlimit = be64_to_cpu(qlvb->qb_warn) << sdp->sd_sb.sb_bsize_shift; 1527 fdq->d_space = be64_to_cpu(qlvb->qb_value) << sdp->sd_sb.sb_bsize_shift; |
1531 1532 gfs2_glock_dq_uninit(&q_gh); 1533out: 1534 qd_put(qd); 1535 return error; 1536} 1537 1538/* GFS2 only supports a subset of the XFS fields */ | 1528 1529 gfs2_glock_dq_uninit(&q_gh); 1530out: 1531 qd_put(qd); 1532 return error; 1533} 1534 1535/* GFS2 only supports a subset of the XFS fields */ |
1539#define GFS2_FIELDMASK (FS_DQ_BSOFT|FS_DQ_BHARD|FS_DQ_BCOUNT) | 1536#define GFS2_FIELDMASK (QC_SPC_SOFT|QC_SPC_HARD|QC_SPACE) |
1540 1541static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid, | 1537 1538static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid, |
1542 struct fs_disk_quota *fdq) | 1539 struct qc_dqblk *fdq) |
1543{ 1544 struct gfs2_sbd *sdp = sb->s_fs_info; 1545 struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode); 1546 struct gfs2_quota_data *qd; 1547 struct gfs2_holder q_gh, i_gh; 1548 unsigned int data_blocks, ind_blocks; 1549 unsigned int blocks = 0; 1550 int alloc_required; --- 27 unchanged lines hidden (view full) --- 1578 goto out_q; 1579 1580 /* Check for existing entry, if none then alloc new blocks */ 1581 error = update_qd(sdp, qd); 1582 if (error) 1583 goto out_i; 1584 1585 /* If nothing has changed, this is a no-op */ | 1540{ 1541 struct gfs2_sbd *sdp = sb->s_fs_info; 1542 struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode); 1543 struct gfs2_quota_data *qd; 1544 struct gfs2_holder q_gh, i_gh; 1545 unsigned int data_blocks, ind_blocks; 1546 unsigned int blocks = 0; 1547 int alloc_required; --- 27 unchanged lines hidden (view full) --- 1575 goto out_q; 1576 1577 /* Check for existing entry, if none then alloc new blocks */ 1578 error = update_qd(sdp, qd); 1579 if (error) 1580 goto out_i; 1581 1582 /* If nothing has changed, this is a no-op */ |
1586 if ((fdq->d_fieldmask & FS_DQ_BSOFT) && 1587 ((fdq->d_blk_softlimit >> sdp->sd_fsb2bb_shift) == be64_to_cpu(qd->qd_qb.qb_warn))) 1588 fdq->d_fieldmask ^= FS_DQ_BSOFT; | 1583 if ((fdq->d_fieldmask & QC_SPC_SOFT) && 1584 ((fdq->d_spc_softlimit >> sdp->sd_sb.sb_bsize_shift) == be64_to_cpu(qd->qd_qb.qb_warn))) 1585 fdq->d_fieldmask ^= QC_SPC_SOFT; |
1589 | 1586 |
1590 if ((fdq->d_fieldmask & FS_DQ_BHARD) && 1591 ((fdq->d_blk_hardlimit >> sdp->sd_fsb2bb_shift) == be64_to_cpu(qd->qd_qb.qb_limit))) 1592 fdq->d_fieldmask ^= FS_DQ_BHARD; | 1587 if ((fdq->d_fieldmask & QC_SPC_HARD) && 1588 ((fdq->d_spc_hardlimit >> sdp->sd_sb.sb_bsize_shift) == be64_to_cpu(qd->qd_qb.qb_limit))) 1589 fdq->d_fieldmask ^= QC_SPC_HARD; |
1593 | 1590 |
1594 if ((fdq->d_fieldmask & FS_DQ_BCOUNT) && 1595 ((fdq->d_bcount >> sdp->sd_fsb2bb_shift) == be64_to_cpu(qd->qd_qb.qb_value))) 1596 fdq->d_fieldmask ^= FS_DQ_BCOUNT; | 1591 if ((fdq->d_fieldmask & QC_SPACE) && 1592 ((fdq->d_space >> sdp->sd_sb.sb_bsize_shift) == be64_to_cpu(qd->qd_qb.qb_value))) 1593 fdq->d_fieldmask ^= QC_SPACE; |
1597 1598 if (fdq->d_fieldmask == 0) 1599 goto out_i; 1600 1601 offset = qd2offset(qd); 1602 alloc_required = gfs2_write_alloc_required(ip, offset, sizeof(struct gfs2_quota)); 1603 if (gfs2_is_stuffed(ip)) 1604 alloc_required = 1; --- 50 unchanged lines hidden --- | 1594 1595 if (fdq->d_fieldmask == 0) 1596 goto out_i; 1597 1598 offset = qd2offset(qd); 1599 alloc_required = gfs2_write_alloc_required(ip, offset, sizeof(struct gfs2_quota)); 1600 if (gfs2_is_stuffed(ip)) 1601 alloc_required = 1; --- 50 unchanged lines hidden --- |