Lines Matching refs:sdp
85 static unsigned int gfs2_qd_hash(const struct gfs2_sbd *sdp, in gfs2_qd_hash() argument
90 h = jhash(&sdp, sizeof(struct gfs2_sbd *), 0); in gfs2_qd_hash()
115 struct gfs2_sbd *sdp; in gfs2_qd_dispose() local
119 sdp = qd->qd_gl->gl_name.ln_sbd; in gfs2_qd_dispose()
132 gfs2_assert_warn(sdp, !qd->qd_change); in gfs2_qd_dispose()
133 gfs2_assert_warn(sdp, !qd->qd_slot_count); in gfs2_qd_dispose()
134 gfs2_assert_warn(sdp, !qd->qd_bh_count); in gfs2_qd_dispose()
137 atomic_dec(&sdp->sd_quota_count); in gfs2_qd_dispose()
211 static struct gfs2_quota_data *qd_alloc(unsigned hash, struct gfs2_sbd *sdp, struct kqid qid) in qd_alloc() argument
220 qd->qd_sbd = sdp; in qd_alloc()
228 error = gfs2_glock_get(sdp, qd2index(qd), in qd_alloc()
241 const struct gfs2_sbd *sdp, in gfs2_qd_search_bucket() argument
250 if (qd->qd_sbd != sdp) in gfs2_qd_search_bucket()
262 static int qd_get(struct gfs2_sbd *sdp, struct kqid qid, in qd_get() argument
266 unsigned int hash = gfs2_qd_hash(sdp, qid); in qd_get()
269 *qdp = qd = gfs2_qd_search_bucket(hash, sdp, qid); in qd_get()
275 new_qd = qd_alloc(hash, sdp, qid); in qd_get()
281 *qdp = qd = gfs2_qd_search_bucket(hash, sdp, qid); in qd_get()
284 list_add(&new_qd->qd_list, &sdp->sd_quota_list); in qd_get()
286 atomic_inc(&sdp->sd_quota_count); in qd_get()
302 struct gfs2_sbd *sdp = qd->qd_gl->gl_name.ln_sbd; in qd_hold() local
303 gfs2_assert(sdp, !__lockref_is_dead(&qd->qd_lockref)); in qd_hold()
320 struct gfs2_sbd *sdp = qd->qd_sbd; in slot_get() local
324 spin_lock(&sdp->sd_bitmap_lock); in slot_get()
329 bit = find_first_zero_bit(sdp->sd_quota_bitmap, sdp->sd_quota_slots); in slot_get()
330 if (bit < sdp->sd_quota_slots) { in slot_get()
331 set_bit(bit, sdp->sd_quota_bitmap); in slot_get()
337 spin_unlock(&sdp->sd_bitmap_lock); in slot_get()
344 struct gfs2_sbd *sdp = qd->qd_sbd; in slot_hold() local
346 spin_lock(&sdp->sd_bitmap_lock); in slot_hold()
347 gfs2_assert(sdp, qd->qd_slot_count); in slot_hold()
349 spin_unlock(&sdp->sd_bitmap_lock); in slot_hold()
354 struct gfs2_sbd *sdp = qd->qd_sbd; in slot_put() local
356 spin_lock(&sdp->sd_bitmap_lock); in slot_put()
357 gfs2_assert(sdp, qd->qd_slot_count); in slot_put()
359 BUG_ON(!test_and_clear_bit(qd->qd_slot, sdp->sd_quota_bitmap)); in slot_put()
362 spin_unlock(&sdp->sd_bitmap_lock); in slot_put()
367 struct gfs2_sbd *sdp = qd->qd_gl->gl_name.ln_sbd; in bh_get() local
368 struct inode *inode = sdp->sd_qc_inode; in bh_get()
375 mutex_lock(&sdp->sd_quota_mutex); in bh_get()
378 mutex_unlock(&sdp->sd_quota_mutex); in bh_get()
382 block = qd->qd_slot / sdp->sd_qc_per_block; in bh_get()
383 offset = qd->qd_slot % sdp->sd_qc_per_block; in bh_get()
399 if (gfs2_metatype_check(sdp, bh, GFS2_METATYPE_QC)) in bh_get()
407 mutex_unlock(&sdp->sd_quota_mutex); in bh_get()
415 mutex_unlock(&sdp->sd_quota_mutex); in bh_get()
421 struct gfs2_sbd *sdp = qd->qd_gl->gl_name.ln_sbd; in bh_put() local
423 mutex_lock(&sdp->sd_quota_mutex); in bh_put()
424 gfs2_assert(sdp, qd->qd_bh_count); in bh_put()
430 mutex_unlock(&sdp->sd_quota_mutex); in bh_put()
433 static int qd_check_sync(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd, in qd_check_sync() argument
444 list_move_tail(&qd->qd_list, &sdp->sd_quota_list); in qd_check_sync()
451 static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) in qd_fish() argument
458 if (sb_rdonly(sdp->sd_vfs)) in qd_fish()
463 list_for_each_entry(iter, &sdp->sd_quota_list, qd_list) { in qd_fish()
464 if (qd_check_sync(sdp, iter, &sdp->sd_quota_sync_gen)) { in qd_fish()
473 gfs2_assert_warn(sdp, qd->qd_change_sync); in qd_fish()
498 static int qdsb_get(struct gfs2_sbd *sdp, struct kqid qid, in qdsb_get() argument
503 error = qd_get(sdp, qid, qdp); in qdsb_get()
538 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_qa_get() local
541 if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF) in gfs2_qa_get()
578 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_quota_hold() local
582 if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF) in gfs2_quota_hold()
591 if (gfs2_assert_warn(sdp, !ip->i_qadata->qa_qd_num) || in gfs2_quota_hold()
592 gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags))) { in gfs2_quota_hold()
597 error = qdsb_get(sdp, make_kqid_uid(ip->i_inode.i_uid), qd); in gfs2_quota_hold()
603 error = qdsb_get(sdp, make_kqid_gid(ip->i_inode.i_gid), qd); in gfs2_quota_hold()
611 error = qdsb_get(sdp, make_kqid_uid(uid), qd); in gfs2_quota_hold()
620 error = qdsb_get(sdp, make_kqid_gid(gid), qd); in gfs2_quota_hold()
636 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_quota_unhold() local
642 gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags)); in gfs2_quota_unhold()
666 struct gfs2_sbd *sdp = qd->qd_gl->gl_name.ln_sbd; in do_qc() local
667 struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); in do_qc()
671 mutex_lock(&sdp->sd_quota_mutex); in do_qc()
690 gfs2_assert_warn(sdp, test_bit(QDF_CHANGE, &qd->qd_flags)); in do_qc()
703 mutex_unlock(&sdp->sd_quota_mutex); in do_qc()
710 struct gfs2_sbd *sdp = GFS2_SB(inode); in gfs2_write_buf_to_page() local
716 unsigned bsize = sdp->sd_sb.sb_bsize, bnum = 0, boff = 0; in gfs2_write_buf_to_page()
720 blk = index << (PAGE_SHIFT - sdp->sd_sb.sb_bsize_shift); in gfs2_write_buf_to_page()
830 struct gfs2_sbd *sdp = GFS2_SB(inode); in gfs2_adjust_quota() local
854 q.qu_warn = cpu_to_be64(fdq->d_spc_softlimit >> sdp->sd_sb.sb_bsize_shift); in gfs2_adjust_quota()
858 q.qu_limit = cpu_to_be64(fdq->d_spc_hardlimit >> sdp->sd_sb.sb_bsize_shift); in gfs2_adjust_quota()
862 q.qu_value = cpu_to_be64(fdq->d_space >> sdp->sd_sb.sb_bsize_shift); in gfs2_adjust_quota()
882 struct gfs2_sbd *sdp = (*qda)->qd_gl->gl_name.ln_sbd; in do_sync() local
883 struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode); in do_sync()
947 error = gfs2_trans_begin(sdp, blocks, 0); in do_sync()
965 gfs2_trans_end(sdp); in do_sync()
982 static int update_qd(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd) in update_qd() argument
984 struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode); in update_qd()
1010 struct gfs2_sbd *sdp = qd->qd_gl->gl_name.ln_sbd; in do_glock() local
1011 struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode); in do_glock()
1036 error = update_qd(sdp, qd); in do_glock()
1057 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_quota_lock() local
1062 if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON) in gfs2_quota_lock()
1092 struct gfs2_sbd *sdp = qd->qd_gl->gl_name.ln_sbd; in need_sync() local
1093 struct gfs2_tune *gt = &sdp->sd_tune; in need_sync()
1116 value *= gfs2_jindex_size(sdp) * num; in need_sync()
1128 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_quota_unlock() local
1149 found = qd_check_sync(sdp, qd, NULL); in gfs2_quota_unlock()
1155 gfs2_assert_warn(sdp, qd->qd_change_sync); in gfs2_quota_unlock()
1179 struct gfs2_sbd *sdp = qd->qd_gl->gl_name.ln_sbd; in print_message() local
1181 fs_info(sdp, "quota %s for %s %u\n", in print_message()
1209 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_quota_check() local
1244 sdp->sd_vfs->s_dev, in gfs2_quota_check()
1252 gfs2_tune_get(sdp, gt_quota_warn_period) in gfs2_quota_check()
1255 sdp->sd_vfs->s_dev, QUOTA_NL_BSOFTWARN); in gfs2_quota_check()
1268 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_quota_change() local
1270 if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON || in gfs2_quota_change()
1271 gfs2_assert_warn(sdp, change)) in gfs2_quota_change()
1276 if (gfs2_assert_withdraw(sdp, ip->i_qadata && in gfs2_quota_change()
1291 struct gfs2_sbd *sdp = sb->s_fs_info; in gfs2_quota_sync() local
1302 mutex_lock(&sdp->sd_quota_sync_mutex); in gfs2_quota_sync()
1303 sdp->sd_quota_sync_gen++; in gfs2_quota_sync()
1309 error = qd_fish(sdp, qda + num_qd); in gfs2_quota_sync()
1322 sdp->sd_quota_sync_gen; in gfs2_quota_sync()
1329 mutex_unlock(&sdp->sd_quota_sync_mutex); in gfs2_quota_sync()
1335 int gfs2_quota_refresh(struct gfs2_sbd *sdp, struct kqid qid) in gfs2_quota_refresh() argument
1341 error = qd_get(sdp, qid, &qd); in gfs2_quota_refresh()
1353 int gfs2_quota_init(struct gfs2_sbd *sdp) in gfs2_quota_init() argument
1355 struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); in gfs2_quota_init()
1356 u64 size = i_size_read(sdp->sd_qc_inode); in gfs2_quota_init()
1357 unsigned int blocks = size >> sdp->sd_sb.sb_bsize_shift; in gfs2_quota_init()
1366 if (gfs2_check_internal_file_size(sdp->sd_qc_inode, 1, 64 << 20)) in gfs2_quota_init()
1369 sdp->sd_quota_slots = blocks * sdp->sd_qc_per_block; in gfs2_quota_init()
1370 bm_size = DIV_ROUND_UP(sdp->sd_quota_slots, 8 * sizeof(unsigned long)); in gfs2_quota_init()
1373 sdp->sd_quota_bitmap = kzalloc(bm_size, GFP_NOFS | __GFP_NOWARN); in gfs2_quota_init()
1374 if (sdp->sd_quota_bitmap == NULL) in gfs2_quota_init()
1375 sdp->sd_quota_bitmap = __vmalloc(bm_size, GFP_NOFS | in gfs2_quota_init()
1377 if (!sdp->sd_quota_bitmap) in gfs2_quota_init()
1395 if (gfs2_metatype_check(sdp, bh, GFS2_METATYPE_QC)) { in gfs2_quota_init()
1401 for (y = 0; y < sdp->sd_qc_per_block && slot < sdp->sd_quota_slots; in gfs2_quota_init()
1414 hash = gfs2_qd_hash(sdp, qc_id); in gfs2_quota_init()
1415 qd = qd_alloc(hash, sdp, qc_id); in gfs2_quota_init()
1427 BUG_ON(test_and_set_bit(slot, sdp->sd_quota_bitmap)); in gfs2_quota_init()
1428 list_add(&qd->qd_list, &sdp->sd_quota_list); in gfs2_quota_init()
1429 atomic_inc(&sdp->sd_quota_count); in gfs2_quota_init()
1445 fs_info(sdp, "found %u quota changes\n", found); in gfs2_quota_init()
1450 gfs2_quota_cleanup(sdp); in gfs2_quota_init()
1454 void gfs2_quota_cleanup(struct gfs2_sbd *sdp) in gfs2_quota_cleanup() argument
1456 struct list_head *head = &sdp->sd_quota_list; in gfs2_quota_cleanup()
1467 atomic_dec(&sdp->sd_quota_count); in gfs2_quota_cleanup()
1474 gfs2_assert_warn(sdp, !qd->qd_change); in gfs2_quota_cleanup()
1475 gfs2_assert_warn(sdp, !qd->qd_slot_count); in gfs2_quota_cleanup()
1476 gfs2_assert_warn(sdp, !qd->qd_bh_count); in gfs2_quota_cleanup()
1485 gfs2_assert_warn(sdp, !atomic_read(&sdp->sd_quota_count)); in gfs2_quota_cleanup()
1487 kvfree(sdp->sd_quota_bitmap); in gfs2_quota_cleanup()
1488 sdp->sd_quota_bitmap = NULL; in gfs2_quota_cleanup()
1491 static void quotad_error(struct gfs2_sbd *sdp, const char *msg, int error) in quotad_error() argument
1495 if (!gfs2_withdrawn(sdp)) { in quotad_error()
1496 if (!cmpxchg(&sdp->sd_log_error, 0, error)) in quotad_error()
1497 fs_err(sdp, "gfs2_quotad: %s error %d\n", msg, error); in quotad_error()
1498 wake_up(&sdp->sd_logd_waitq); in quotad_error()
1502 static void quotad_check_timeo(struct gfs2_sbd *sdp, const char *msg, in quotad_check_timeo() argument
1508 int error = fxn(sdp->sd_vfs, 0); in quotad_check_timeo()
1509 quotad_error(sdp, msg, error); in quotad_check_timeo()
1510 *timeo = gfs2_tune_get_i(&sdp->sd_tune, new_timeo) * HZ; in quotad_check_timeo()
1516 void gfs2_wake_up_statfs(struct gfs2_sbd *sdp) { in gfs2_wake_up_statfs() argument
1517 if (!sdp->sd_statfs_force_sync) { in gfs2_wake_up_statfs()
1518 sdp->sd_statfs_force_sync = 1; in gfs2_wake_up_statfs()
1519 wake_up(&sdp->sd_quota_wait); in gfs2_wake_up_statfs()
1532 struct gfs2_sbd *sdp = data; in gfs2_quotad() local
1533 struct gfs2_tune *tune = &sdp->sd_tune; in gfs2_quotad()
1541 if (gfs2_withdrawn(sdp)) in gfs2_quotad()
1544 if (sdp->sd_statfs_force_sync) { in gfs2_quotad()
1545 int error = gfs2_statfs_sync(sdp->sd_vfs, 0); in gfs2_quotad()
1546 quotad_error(sdp, "statfs", error); in gfs2_quotad()
1547 statfs_timeo = gfs2_tune_get(sdp, gt_statfs_quantum) * HZ; in gfs2_quotad()
1550 quotad_check_timeo(sdp, "statfs", gfs2_statfs_sync, t, in gfs2_quotad()
1555 quotad_check_timeo(sdp, "sync", gfs2_quota_sync, t, in gfs2_quotad()
1563 prepare_to_wait(&sdp->sd_quota_wait, &wait, TASK_INTERRUPTIBLE); in gfs2_quotad()
1564 if (!sdp->sd_statfs_force_sync) in gfs2_quotad()
1568 finish_wait(&sdp->sd_quota_wait, &wait); in gfs2_quotad()
1576 struct gfs2_sbd *sdp = sb->s_fs_info; in gfs2_quota_get_state() local
1580 switch (sdp->sd_args.ar_quota) { in gfs2_quota_get_state()
1594 if (sdp->sd_quota_inode) { in gfs2_quota_get_state()
1596 GFS2_I(sdp->sd_quota_inode)->i_no_addr; in gfs2_quota_get_state()
1597 state->s_state[USRQUOTA].blocks = sdp->sd_quota_inode->i_blocks; in gfs2_quota_get_state()
1608 struct gfs2_sbd *sdp = sb->s_fs_info; in gfs2_get_dqblk() local
1616 if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF) in gfs2_get_dqblk()
1623 error = qd_get(sdp, qid, &qd); in gfs2_get_dqblk()
1631 fdq->d_spc_hardlimit = be64_to_cpu(qlvb->qb_limit) << sdp->sd_sb.sb_bsize_shift; in gfs2_get_dqblk()
1632 fdq->d_spc_softlimit = be64_to_cpu(qlvb->qb_warn) << sdp->sd_sb.sb_bsize_shift; in gfs2_get_dqblk()
1633 fdq->d_space = be64_to_cpu(qlvb->qb_value) << sdp->sd_sb.sb_bsize_shift; in gfs2_get_dqblk()
1647 struct gfs2_sbd *sdp = sb->s_fs_info; in gfs2_set_dqblk() local
1648 struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode); in gfs2_set_dqblk()
1657 if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF) in gfs2_set_dqblk()
1667 error = qd_get(sdp, qid, &qd); in gfs2_set_dqblk()
1684 error = update_qd(sdp, qd); in gfs2_set_dqblk()
1690 ((fdq->d_spc_softlimit >> sdp->sd_sb.sb_bsize_shift) == be64_to_cpu(qd->qd_qb.qb_warn))) in gfs2_set_dqblk()
1694 ((fdq->d_spc_hardlimit >> sdp->sd_sb.sb_bsize_shift) == be64_to_cpu(qd->qd_qb.qb_limit))) in gfs2_set_dqblk()
1698 ((fdq->d_space >> sdp->sd_sb.sb_bsize_shift) == be64_to_cpu(qd->qd_qb.qb_value))) in gfs2_set_dqblk()
1722 error = gfs2_trans_begin(sdp, blocks + RES_DINODE + 2, 0); in gfs2_set_dqblk()
1731 gfs2_trans_end(sdp); in gfs2_set_dqblk()