X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-ldiskfs%2Fosd_handler.c;h=13e710c9fdfd902527618371cd3a54ce74bbcfea;hb=0098396983e1075668414aa5298a4990e61ffbda;hp=5a87b266fb03e28c605e4217a3a5e278ee4b80d5;hpb=4cb6ce1863d0498ece59dabe6d38ef12c0a5fd41;p=fs%2Flustre-release.git diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 5a87b26..13e710c 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -42,9 +42,7 @@ #include #include #include -#ifdef HAVE_UIDGID_HEADER -# include -#endif +#include /* prerequisite for linux/xattr.h */ #include @@ -495,13 +493,13 @@ int osd_ldiskfs_add_entry(struct osd_thread_info *info, struct osd_device *osd, } if (fid != NULL) - CWARN("%s: directory (inode: %lu, FID: "DFID") %s " - "maximum entry limit\n", + /* below message is checked in sanity.sh test_129 */ + CWARN("%s: directory (inode: %lu, FID: "DFID") %s maximum entry limit\n", osd_name(osd), parent->i_ino, PFID(fid), rc == -ENOSPC ? "has reached" : "is approaching"); else - CWARN("%s: directory (inode: %lu, FID: unknown) %s " - "maximum entry limit\n", + /* below message is checked in sanity.sh test_129 */ + CWARN("%s: directory (inode: %lu, FID: unknown) %s maximum entry limit\n", osd_name(osd), parent->i_ino, rc == -ENOSPC ? "has reached" : "is approaching"); @@ -855,10 +853,8 @@ static int osd_check_lma(const struct lu_env *env, struct osd_object *obj) } struct osd_check_lmv_buf { -#ifdef HAVE_DIR_CONTEXT /* please keep it as first member */ struct dir_context ctx; -#endif struct osd_thread_info *oclb_info; struct osd_device *oclb_dev; struct osd_idmap_cache *oclb_oic; @@ -867,7 +863,7 @@ struct osd_check_lmv_buf { }; /** - * It is called internally by ->readdir() to filter out the + * It is called internally by ->iterate*() to filter out the * local slave object's FID of the striped directory. * * \retval 1 found the local slave's FID @@ -964,9 +960,7 @@ static int osd_check_lmv(struct osd_thread_info *oti, struct osd_device *dev, const struct file_operations *fops; struct lmv_mds_md_v1 *lmv1; struct osd_check_lmv_buf oclb = { -#ifdef HAVE_DIR_CONTEXT .ctx.actor = osd_stripe_dir_filldir, -#endif .oclb_info = oti, .oclb_dev = dev, .oclb_oic = oic, @@ -1013,25 +1007,20 @@ again: dentry->d_sb = inode->i_sb; filp->f_pos = 0; filp->f_path.dentry = dentry; - filp->f_mode = FMODE_64BITHASH; + filp->f_flags |= O_NOATIME; + filp->f_mode = FMODE_64BITHASH | FMODE_NONOTIFY; filp->f_mapping = inode->i_mapping; filp->f_op = fops; filp->private_data = NULL; + filp->f_cred = current_cred(); set_file_inode(filp, inode); + rc = osd_security_file_alloc(filp); + if (rc) + goto out; do { oclb.oclb_items = 0; -#ifdef HAVE_DIR_CONTEXT - oclb.ctx.pos = filp->f_pos; -#ifdef HAVE_ITERATE_SHARED - rc = fops->iterate_shared(filp, &oclb.ctx); -#else - rc = fops->iterate(filp, &oclb.ctx); -#endif - filp->f_pos = oclb.ctx.pos; -#else - rc = fops->readdir(filp, &oclb, osd_stripe_dir_filldir); -#endif + rc = iterate_dir(filp, &oclb.ctx); } while (rc >= 0 && oclb.oclb_items > 0 && !oclb.oclb_found && filp->f_pos != LDISKFS_HTREE_EOF_64BIT); fops->release(inode, filp); @@ -1883,7 +1872,7 @@ static int osd_trans_start(const struct lu_env *env, struct dt_device *d, */ if (last_credits != oh->ot_credits && time_after(jiffies, last_printed + - msecs_to_jiffies(60 * MSEC_PER_SEC)) && + cfs_time_seconds(60)) && osd_transaction_size(dev) > 512) { CWARN("%s: credits %u > trans_max %u\n", osd_name(dev), oh->ot_credits, osd_transaction_size(dev)); @@ -1989,7 +1978,7 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt, struct osd_device *osd = osd_dt_dev(th->th_dev); struct qsd_instance *qsd = osd_def_qsd(osd); struct lquota_trans *qtrans; - struct list_head truncates = LIST_HEAD_INIT(truncates); + LIST_HEAD(truncates); int rc = 0, remove_agents = 0; ENTRY; @@ -2190,7 +2179,7 @@ static int osd_object_print(const struct lu_env *env, void *cookie, * Concurrency: shouldn't matter. */ int osd_statfs(const struct lu_env *env, struct dt_device *d, - struct obd_statfs *sfs) + struct obd_statfs *sfs, struct obd_statfs_info *info) { struct osd_device *osd = osd_dt_dev(d); struct super_block *sb = osd_sb(osd); @@ -2215,7 +2204,7 @@ int osd_statfs(const struct lu_env *env, struct dt_device *d, goto out; statfs_pack(sfs, ksfs); - if (unlikely(sb->s_flags & MS_RDONLY)) + if (unlikely(sb->s_flags & SB_RDONLY)) sfs->os_state |= OS_STATE_READONLY; sfs->os_state |= osd->od_nonrotational ? OS_STATE_NONROT : 0; @@ -2233,7 +2222,7 @@ int osd_statfs(const struct lu_env *env, struct dt_device *d, * * Reserve 0.78% of total space, at least 8MB for small filesystems. */ - CLASSERT(OSD_STATFS_RESERVED > LDISKFS_MAX_BLOCK_SIZE); + BUILD_BUG_ON(OSD_STATFS_RESERVED <= LDISKFS_MAX_BLOCK_SIZE); reserved = OSD_STATFS_RESERVED >> sb->s_blocksize_bits; if (likely(sfs->os_blocks >= reserved << OSD_STATFS_RESERVED_SHIFT)) reserved = sfs->os_blocks >> OSD_STATFS_RESERVED_SHIFT; @@ -2319,8 +2308,8 @@ static void osd_conf_get(const struct lu_env *env, #endif param->ddp_max_ea_size = sb->s_blocksize - ea_overhead; - if (param->ddp_max_ea_size > OBD_MAX_EA_SIZE - ea_overhead) - param->ddp_max_ea_size = OBD_MAX_EA_SIZE - ea_overhead; + if (param->ddp_max_ea_size > OBD_MAX_EA_SIZE) + param->ddp_max_ea_size = OBD_MAX_EA_SIZE; /* * Preferred RPC size for efficient disk IO. 4MB shows good @@ -2438,6 +2427,14 @@ static int osd_commit_async(const struct lu_env *env, static int (*priv_dev_set_rdonly)(struct block_device *bdev); static int (*priv_dev_check_rdonly)(struct block_device *bdev); /* static int (*priv_dev_clear_rdonly)(struct block_device *bdev); */ +static int (*priv_security_file_alloc)(struct file *file); + +int osd_security_file_alloc(struct file *file) +{ + if (priv_security_file_alloc) + return priv_security_file_alloc(file); + return 0; +} /* * Concurrency: shouldn't matter. @@ -2798,9 +2795,10 @@ static int osd_declare_attr_set(const struct lu_env *env, RETURN(rc); gid = i_gid_read(obj->oo_inode); + CDEBUG(D_QUOTA, "declare uid %d -> %d gid %d -> %d\n", uid, + attr->la_uid, gid, attr->la_gid); enforce = (attr->la_valid & LA_GID) && (attr->la_gid != gid); - rc = osd_declare_attr_qid(env, obj, oh, bspace, - i_gid_read(obj->oo_inode), + rc = osd_declare_attr_qid(env, obj, oh, bspace, gid, attr->la_gid, enforce, GRPQUOTA, ignore_edquot); if (rc) @@ -2943,7 +2941,12 @@ static int osd_quota_transfer(struct inode *inode, const struct lu_attr *attr) (attr->la_valid & LA_GID && attr->la_gid != i_gid_read(inode))) { struct iattr iattr; - ll_vfs_dq_init(inode); + CDEBUG(D_QUOTA, + "executing dquot_transfer inode %ld uid %d -> %d gid %d -> %d\n", + inode->i_ino, i_uid_read(inode), attr->la_uid, + i_gid_read(inode), attr->la_gid); + + dquot_initialize(inode); iattr.ia_valid = 0; if (attr->la_valid & LA_UID) iattr.ia_valid |= ATTR_UID; @@ -2952,7 +2955,7 @@ static int osd_quota_transfer(struct inode *inode, const struct lu_attr *attr) iattr.ia_uid = make_kuid(&init_user_ns, attr->la_uid); iattr.ia_gid = make_kgid(&init_user_ns, attr->la_gid); - rc = ll_vfs_dq_transfer(inode, &iattr); + rc = dquot_transfer(inode, &iattr); if (rc) { CERROR("%s: quota transfer failed: rc = %d. Is quota " "enforcement enabled on the ldiskfs " @@ -3038,6 +3041,8 @@ static int osd_attr_set(const struct lu_env *env, ll_dirty_inode(inode, I_DIRTY_DATASYNC); + osd_trans_exec_check(env, handle, OSD_OT_ATTR_SET); + if (!(attr->la_valid & LA_FLAGS)) GOTO(out, rc); @@ -3056,6 +3061,9 @@ static int osd_attr_set(const struct lu_env *env, lma->lma_incompat |= lustre_to_lma_flags(attr->la_flags); lustre_lma_swab(lma); + + osd_trans_exec_op(env, handle, OSD_OT_XATTR_SET); + rc = __osd_xattr_set(info, inode, XATTR_NAME_LMA, lma, sizeof(*lma), XATTR_REPLACE); if (rc != 0) { @@ -3071,7 +3079,6 @@ static int osd_attr_set(const struct lu_env *env, osd_trans_exec_check(env, handle, OSD_OT_XATTR_SET); } out: - osd_trans_exec_check(env, handle, OSD_OT_ATTR_SET); return rc; } @@ -3828,7 +3835,7 @@ static struct inode *osd_create_local_agent_inode(const struct lu_env *env, * debugging if we need to determine where this symlink came from. */ if (S_ISLNK(type)) { - CLASSERT(LDISKFS_N_BLOCKS * 4 >= FID_LEN + 1); + BUILD_BUG_ON(LDISKFS_N_BLOCKS * 4 < FID_LEN + 1); rc = snprintf((char *)LDISKFS_I(local)->i_data, LDISKFS_N_BLOCKS * 4, DFID, PFID(fid)); @@ -3912,20 +3919,16 @@ static int osd_process_scheduled_agent_removals(const struct lu_env *env, struct osd_thread_info *info = osd_oti_get(env); struct osd_obj_orphan *oor, *tmp; struct osd_inode_id id; - struct list_head list; + LIST_HEAD(list); struct inode *inode; struct lu_fid fid; handle_t *jh; __u32 ino; - INIT_LIST_HEAD(&list); - spin_lock(&osd->od_osfs_lock); list_for_each_entry_safe(oor, tmp, &osd->od_orphan_list, oor_list) { - if (oor->oor_env == env) { - list_del(&oor->oor_list); - list_add(&oor->oor_list, &list); - } + if (oor->oor_env == env) + list_move(&oor->oor_list, &list); } spin_unlock(&osd->od_osfs_lock); @@ -4437,7 +4440,7 @@ static int osd_xattr_set_pfid(const struct lu_env *env, struct osd_object *obj, RETURN(fl); /* Remove old PFID EA entry firstly. */ - ll_vfs_dq_init(inode); + dquot_initialize(inode); rc = osd_removexattr(dentry, inode, XATTR_NAME_FID); if (rc == -ENODATA) { if ((fl & LU_XATTR_REPLACE) && !(fl & LU_XATTR_CREATE)) @@ -4741,7 +4744,7 @@ static int osd_xattr_del(const struct lu_env *env, struct dt_object *dt, obj->oo_pfid_in_lma = 0; } } else { - ll_vfs_dq_init(inode); + dquot_initialize(inode); dentry->d_inode = inode; dentry->d_sb = inode->i_sb; rc = osd_removexattr(dentry, inode, name); @@ -5192,7 +5195,7 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt, LASSERT(oh->ot_handle != NULL); LASSERT(oh->ot_handle->h_transaction != NULL); - ll_vfs_dq_init(dir); + dquot_initialize(dir); dentry = osd_child_dentry_get(env, obj, (char *)key, strlen((char *)key)); @@ -5427,7 +5430,7 @@ static int __osd_ea_add_rec(struct osd_thread_info *info, osd_get_ldiskfs_dirent_param(ldp, fid); child = osd_child_dentry_get(info->oti_env, pobj, name, strlen(name)); child->d_fsdata = (void *)ldp; - ll_vfs_dq_init(pobj->oo_inode); + dquot_initialize(pobj->oo_inode); rc = osd_ldiskfs_add_entry(info, osd_obj2dev(pobj), oth->ot_handle, child, cinode, hlock); if (rc == 0 && OBD_FAIL_CHECK(OBD_FAIL_LFSCK_BAD_TYPE)) { @@ -6519,13 +6522,11 @@ static void osd_it_ea_put(const struct lu_env *env, struct dt_it *di) } struct osd_filldir_cbs { -#ifdef HAVE_DIR_CONTEXT struct dir_context ctx; -#endif struct osd_it_ea *it; }; /** - * It is called internally by ->readdir(). It fills the + * It is called internally by ->iterate*(). It fills the * iterator's in-memory data structure with required * information i.e. name, namelen, rec_size etc. * @@ -6592,7 +6593,7 @@ static int osd_ldiskfs_filldir(void *buf, } /** - * Calls ->readdir() to load a directory entry at a time + * Calls ->iterate*() to load a directory entry at a time * and stored it in iterator's in-memory data structure. * * \param di iterator's in memory structure @@ -6611,9 +6612,7 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env, struct file *filp = &it->oie_file; int rc = 0; struct osd_filldir_cbs buf = { -#ifdef HAVE_DIR_CONTEXT .ctx.actor = osd_ldiskfs_filldir, -#endif .it = it }; @@ -6629,17 +6628,16 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env, down_read(&obj->oo_ext_idx_sem); } -#ifdef HAVE_DIR_CONTEXT - buf.ctx.pos = filp->f_pos; -#ifdef HAVE_ITERATE_SHARED - rc = inode->i_fop->iterate_shared(filp, &buf.ctx); -#else - rc = inode->i_fop->iterate(filp, &buf.ctx); -#endif - filp->f_pos = buf.ctx.pos; -#else - rc = inode->i_fop->readdir(filp, &buf, osd_ldiskfs_filldir); -#endif + filp->f_cred = current_cred(); + rc = osd_security_file_alloc(filp); + if (rc) + RETURN(rc); + + filp->f_flags |= O_NOATIME; + filp->f_mode |= FMODE_NONOTIFY; + rc = iterate_dir(filp, &buf.ctx); + if (rc) + RETURN(rc); if (hlock != NULL) ldiskfs_htree_unlock(hlock); @@ -6663,7 +6661,7 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env, } /** - * It calls osd_ldiskfs_it_fill() which will use ->readdir() + * It calls osd_ldiskfs_it_fill() which will use ->iterate*() * to load a directory entry at a time and stored it in * iterator's in-memory data structure. * @@ -6794,7 +6792,7 @@ osd_dirent_reinsert(const struct lu_env *env, struct osd_device *dev, ldp = (struct ldiskfs_dentry_param *)osd_oti_get(env)->oti_ldp; osd_get_ldiskfs_dirent_param(ldp, fid); dentry->d_fsdata = (void *)ldp; - ll_vfs_dq_init(dir); + dquot_initialize(dir); rc = osd_ldiskfs_add_entry(info, dev, jh, dentry, inode, hlock); /* * It is too bad, we cannot reinsert the name entry back. @@ -7276,7 +7274,7 @@ static __u64 osd_it_ea_store(const struct lu_env *env, const struct dt_it *di) } /** - * It calls osd_ldiskfs_it_fill() which will use ->readdir() + * It calls osd_ldiskfs_it_fill() which will use ->iterate*() * to load a directory entry at a time and stored it i inn, * in iterator's in-memory data structure. * @@ -7783,7 +7781,8 @@ static int osd_device_init0(const struct lu_env *env, o->od_read_cache = 1; o->od_writethrough_cache = 1; o->od_readcache_max_filesize = OSD_MAX_CACHE_SIZE; - + o->od_readcache_max_iosize = OSD_READCACHE_MAX_IO_MB << 20; + o->od_writethrough_max_iosize = OSD_WRITECACHE_MAX_IO_MB << 20; o->od_auto_scrub_interval = AS_DEFAULT; cplen = strlcpy(o->od_svname, lustre_cfg_string(cfg, 4), @@ -8147,13 +8146,13 @@ static int osd_health_check(const struct lu_env *env, struct obd_device *obd) struct osd_device *osd = osd_dev(obd->obd_lu_dev); struct super_block *sb = osd_sb(osd); - return (osd->od_mnt == NULL || sb->s_flags & MS_RDONLY); + return (osd->od_mnt == NULL || sb->s_flags & SB_RDONLY); } /* * lprocfs legacy support. */ -static struct obd_ops osd_obd_device_ops = { +static const struct obd_ops osd_obd_device_ops = { .o_owner = THIS_MODULE, .o_connect = osd_obd_connect, .o_disconnect = osd_obd_disconnect, @@ -8190,10 +8189,11 @@ static int __init osd_init(void) struct kobject *kobj; int rc; - CLASSERT(BH_DXLock < sizeof(((struct buffer_head *)0)->b_state) * 8); + BUILD_BUG_ON(BH_DXLock >= + sizeof(((struct buffer_head *)0)->b_state) * 8); #if !defined(CONFIG_DEBUG_MUTEXES) && !defined(CONFIG_DEBUG_SPINLOCK) /* please, try to keep osd_thread_info smaller than a page */ - CLASSERT(sizeof(struct osd_thread_info) <= PAGE_SIZE); + BUILD_BUG_ON(sizeof(struct osd_thread_info) > PAGE_SIZE); #endif osd_oi_mod_init(); @@ -8203,6 +8203,8 @@ static int __init osd_init(void) return rc; #ifdef CONFIG_KALLSYMS + priv_security_file_alloc = + (void *)kallsyms_lookup_name("security_file_alloc"); priv_dev_set_rdonly = (void *)kallsyms_lookup_name("dev_set_rdonly"); priv_dev_check_rdonly = (void *)kallsyms_lookup_name("dev_check_rdonly");