dquot.c (a4eb8b993554d374002663200bf5721f7f2ee259) | dquot.c (7a9ca53aea10ad4677a0f347ad7639c304b80194) |
---|---|
1/* 2 * Implementation of the diskquota system for the LINUX operating system. QUOTA 3 * is implemented using the BSD system call interface as the means of 4 * communication with the user level. This file contains the generic routines 5 * called by the different filesystems on allocation of an inode or block. 6 * These routines take care of the administration needed to have a consistent 7 * diskquota tracking system. The ideas of both user and group quotas are based 8 * on the Melbourne quota system as used on BSD derived systems. The internal --- 1896 unchanged lines hidden (view full) --- 1905 * 1906 * We are holding reference on transfer_from & transfer_to, no need to 1907 * protect them by srcu_read_lock(). 1908 */ 1909int __dquot_transfer(struct inode *inode, struct dquot **transfer_to) 1910{ 1911 qsize_t space, cur_space; 1912 qsize_t rsv_space = 0; | 1/* 2 * Implementation of the diskquota system for the LINUX operating system. QUOTA 3 * is implemented using the BSD system call interface as the means of 4 * communication with the user level. This file contains the generic routines 5 * called by the different filesystems on allocation of an inode or block. 6 * These routines take care of the administration needed to have a consistent 7 * diskquota tracking system. The ideas of both user and group quotas are based 8 * on the Melbourne quota system as used on BSD derived systems. The internal --- 1896 unchanged lines hidden (view full) --- 1905 * 1906 * We are holding reference on transfer_from & transfer_to, no need to 1907 * protect them by srcu_read_lock(). 1908 */ 1909int __dquot_transfer(struct inode *inode, struct dquot **transfer_to) 1910{ 1911 qsize_t space, cur_space; 1912 qsize_t rsv_space = 0; |
1913 qsize_t inode_usage = 1; |
|
1913 struct dquot *transfer_from[MAXQUOTAS] = {}; 1914 int cnt, ret = 0; 1915 char is_valid[MAXQUOTAS] = {}; 1916 struct dquot_warn warn_to[MAXQUOTAS]; 1917 struct dquot_warn warn_from_inodes[MAXQUOTAS]; 1918 struct dquot_warn warn_from_space[MAXQUOTAS]; 1919 1920 if (IS_NOQUOTA(inode)) 1921 return 0; | 1914 struct dquot *transfer_from[MAXQUOTAS] = {}; 1915 int cnt, ret = 0; 1916 char is_valid[MAXQUOTAS] = {}; 1917 struct dquot_warn warn_to[MAXQUOTAS]; 1918 struct dquot_warn warn_from_inodes[MAXQUOTAS]; 1919 struct dquot_warn warn_from_space[MAXQUOTAS]; 1920 1921 if (IS_NOQUOTA(inode)) 1922 return 0; |
1923 1924 if (inode->i_sb->dq_op->get_inode_usage) { 1925 ret = inode->i_sb->dq_op->get_inode_usage(inode, &inode_usage); 1926 if (ret) 1927 return ret; 1928 } 1929 |
|
1922 /* Initialize the arrays */ 1923 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1924 warn_to[cnt].w_type = QUOTA_NL_NOWARN; 1925 warn_from_inodes[cnt].w_type = QUOTA_NL_NOWARN; 1926 warn_from_space[cnt].w_type = QUOTA_NL_NOWARN; 1927 } 1928 1929 spin_lock(&dq_data_lock); --- 11 unchanged lines hidden (view full) --- 1941 */ 1942 if (!transfer_to[cnt]) 1943 continue; 1944 /* Avoid races with quotaoff() */ 1945 if (!sb_has_quota_active(inode->i_sb, cnt)) 1946 continue; 1947 is_valid[cnt] = 1; 1948 transfer_from[cnt] = i_dquot(inode)[cnt]; | 1930 /* Initialize the arrays */ 1931 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1932 warn_to[cnt].w_type = QUOTA_NL_NOWARN; 1933 warn_from_inodes[cnt].w_type = QUOTA_NL_NOWARN; 1934 warn_from_space[cnt].w_type = QUOTA_NL_NOWARN; 1935 } 1936 1937 spin_lock(&dq_data_lock); --- 11 unchanged lines hidden (view full) --- 1949 */ 1950 if (!transfer_to[cnt]) 1951 continue; 1952 /* Avoid races with quotaoff() */ 1953 if (!sb_has_quota_active(inode->i_sb, cnt)) 1954 continue; 1955 is_valid[cnt] = 1; 1956 transfer_from[cnt] = i_dquot(inode)[cnt]; |
1949 ret = check_idq(transfer_to[cnt], 1, &warn_to[cnt]); | 1957 ret = check_idq(transfer_to[cnt], inode_usage, &warn_to[cnt]); |
1950 if (ret) 1951 goto over_quota; 1952 ret = check_bdq(transfer_to[cnt], space, 0, &warn_to[cnt]); 1953 if (ret) 1954 goto over_quota; 1955 } 1956 1957 /* 1958 * Finally perform the needed transfer from transfer_from to transfer_to 1959 */ 1960 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1961 if (!is_valid[cnt]) 1962 continue; 1963 /* Due to IO error we might not have transfer_from[] structure */ 1964 if (transfer_from[cnt]) { 1965 int wtype; | 1958 if (ret) 1959 goto over_quota; 1960 ret = check_bdq(transfer_to[cnt], space, 0, &warn_to[cnt]); 1961 if (ret) 1962 goto over_quota; 1963 } 1964 1965 /* 1966 * Finally perform the needed transfer from transfer_from to transfer_to 1967 */ 1968 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1969 if (!is_valid[cnt]) 1970 continue; 1971 /* Due to IO error we might not have transfer_from[] structure */ 1972 if (transfer_from[cnt]) { 1973 int wtype; |
1966 wtype = info_idq_free(transfer_from[cnt], 1); | 1974 wtype = info_idq_free(transfer_from[cnt], inode_usage); |
1967 if (wtype != QUOTA_NL_NOWARN) 1968 prepare_warning(&warn_from_inodes[cnt], 1969 transfer_from[cnt], wtype); 1970 wtype = info_bdq_free(transfer_from[cnt], space); 1971 if (wtype != QUOTA_NL_NOWARN) 1972 prepare_warning(&warn_from_space[cnt], 1973 transfer_from[cnt], wtype); | 1975 if (wtype != QUOTA_NL_NOWARN) 1976 prepare_warning(&warn_from_inodes[cnt], 1977 transfer_from[cnt], wtype); 1978 wtype = info_bdq_free(transfer_from[cnt], space); 1979 if (wtype != QUOTA_NL_NOWARN) 1980 prepare_warning(&warn_from_space[cnt], 1981 transfer_from[cnt], wtype); |
1974 dquot_decr_inodes(transfer_from[cnt], 1); | 1982 dquot_decr_inodes(transfer_from[cnt], inode_usage); |
1975 dquot_decr_space(transfer_from[cnt], cur_space); 1976 dquot_free_reserved_space(transfer_from[cnt], 1977 rsv_space); 1978 } 1979 | 1983 dquot_decr_space(transfer_from[cnt], cur_space); 1984 dquot_free_reserved_space(transfer_from[cnt], 1985 rsv_space); 1986 } 1987 |
1980 dquot_incr_inodes(transfer_to[cnt], 1); | 1988 dquot_incr_inodes(transfer_to[cnt], inode_usage); |
1981 dquot_incr_space(transfer_to[cnt], cur_space); 1982 dquot_resv_space(transfer_to[cnt], rsv_space); 1983 1984 i_dquot(inode)[cnt] = transfer_to[cnt]; 1985 } 1986 spin_unlock(&dq_data_lock); 1987 1988 mark_all_dquot_dirty(transfer_from); --- 958 unchanged lines hidden --- | 1989 dquot_incr_space(transfer_to[cnt], cur_space); 1990 dquot_resv_space(transfer_to[cnt], rsv_space); 1991 1992 i_dquot(inode)[cnt] = transfer_to[cnt]; 1993 } 1994 spin_unlock(&dq_data_lock); 1995 1996 mark_all_dquot_dirty(transfer_from); --- 958 unchanged lines hidden --- |