From: yury Date: Wed, 6 Jul 2005 12:41:36 +0000 (+0000) Subject: - removed not used vars in client_obd_setup() X-Git-Tag: 1.4.10~932 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=97ebd165594e5f2027436464c79bdc176b3a6cc9;p=fs%2Flustre-release.git - removed not used vars in client_obd_setup() - many fixes and improvements suggested by Andreas - removed not used function inode_update_time() --- diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 104acc0..f75d73f 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -218,6 +218,7 @@ struct filter_obd { int fo_committed_group; spinlock_t fo_objidlock; /* protect fo_lastobjid increment */ + spinlock_t fo_lastidlock; /* protect last_id increment */ spinlock_t fo_translock; /* protect fsd_last_rcvd increment */ struct file *fo_rcvd_filp; struct filter_server_data *fo_fsd; diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 5655934..b9f030b 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -181,8 +181,6 @@ int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf) char *name = obddev->obd_type->typ_name; char *mgmt_name = NULL; int rc; - struct obd_device *mgmt_obd; - mgmtcli_register_for_events_t register_f; ENTRY; /* In a more perfect world, we would hang a ptlrpc_client off of diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index f7cd494..2dcea73 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -423,9 +423,6 @@ mds_create_objects(struct obd_device *obd, struct ptlrpc_request *req, rc = obd_create(mds->mds_dt_exp, oa, NULL, 0, &lsm, &oti); if (rc) { - int level = D_ERROR; - if (rc == -ENOSPC) - level = D_INODE; CDEBUG((rc == -ENOSPC ? D_INODE : D_ERROR), "error creating objects for " "inode %lu: rc = %d\n", diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 80a55f7..cf341c0 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -1043,6 +1043,17 @@ __u64 filter_last_id(struct filter_obd *filter, int group) return id; } +static void filter_save_last_id(struct filter_obd *filter, int group, obd_id id) +{ + LASSERT(group > 0); + LASSERT(group < filter->fo_group_count); + + spin_lock(&filter->fo_lastidlock); + if (id > filter_last_id(filter, group)) + filter_set_last_id(filter, group, id); + spin_unlock(&filter->fo_lastidlock); +} + /* direct cut-n-paste of mds_blocking_ast() */ static int filter_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, @@ -1499,6 +1510,7 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf, spin_lock_init(&filter->fo_translock); spin_lock_init(&filter->fo_objidlock); + spin_lock_init(&filter->fo_lastidlock); INIT_LIST_HEAD(&filter->fo_export_list); sema_init(&filter->fo_alloc_lock, 1); spin_lock_init(&filter->fo_r_pages.oh_lock); @@ -2169,6 +2181,8 @@ int filter_setattr(struct obd_export *exp, struct obdo *oa, struct filter_obd *filter; struct ldlm_resource *res; struct dentry *dentry; + obd_uid uid; + obd_gid gid; int rc; ENTRY; @@ -2177,9 +2191,12 @@ int filter_setattr(struct obd_export *exp, struct obdo *oa, filter = &exp->exp_obd->u.filter; push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); + uid = oa->o_valid & OBD_MD_FLUID ? oa->o_uid : 0; + gid = oa->o_valid & OBD_MD_FLGID ? oa->o_gid : 0; + /* make sure that object is allocated. */ - dentry = filter_crow_object(exp->exp_obd, - oa->o_gr, oa->o_id); + dentry = filter_crow_object(exp->exp_obd, oa->o_gr, + oa->o_id, uid, gid); if (IS_ERR(dentry)) GOTO(out_pop, rc = PTR_ERR(dentry)); @@ -2293,13 +2310,12 @@ static int filter_statfs(struct obd_device *obd, struct obd_statfs *osfs, RETURN(rc); } -int filter_create_object(struct obd_device *obd, struct obdo *oa, - obd_gr group) +int filter_create_object(struct obd_device *obd, obd_gr group, obd_id id, + obd_uid uid, obd_gid gid) { struct dentry *dparent = NULL; struct dentry *dchild = NULL; struct filter_obd *filter; - struct obd_statfs *osfs; int cleanup_phase = 0; int err = 0, rc = 0; void *handle = NULL; @@ -2308,35 +2324,22 @@ int filter_create_object(struct obd_device *obd, struct obdo *oa, filter = &obd->u.filter; - OBD_ALLOC(osfs, sizeof(*osfs)); - if (osfs == NULL) - RETURN(-ENOMEM); - rc = filter_statfs(obd, osfs, jiffies - HZ); - if (rc == 0 && osfs->os_bavail < (osfs->os_blocks >> 10)) { - CDEBUG(D_HA, "OST out of space! avail "LPU64"\n", - osfs->os_bavail << filter->fo_sb->s_blocksize_bits); - rc = -ENOSPC; - } - OBD_FREE(osfs, sizeof(*osfs)); - if (rc) - RETURN(rc); - down(&filter->fo_create_locks[group]); if (test_bit(group, &filter->fo_destroys_in_progress)) { - CWARN("%s: precreate aborted by destroy\n", + CWARN("%s: create aborted by destroy\n", obd->obd_name); GOTO(out, rc = -EALREADY); } - CDEBUG(D_INFO, "precreate objid "LPU64"\n", oa->o_id); + CDEBUG(D_INFO, "create objid "LPU64"\n", id); - dparent = filter_parent_lock(obd, group, oa->o_id, &lock); + dparent = filter_parent_lock(obd, group, id, &lock); if (IS_ERR(dparent)) GOTO(cleanup, rc = PTR_ERR(dparent)); cleanup_phase = 1; - dchild = filter_id2dentry(obd, dparent, group, oa->o_id); + dchild = filter_id2dentry(obd, dparent, group, id); if (IS_ERR(dchild)) GOTO(cleanup, rc = PTR_ERR(dchild)); cleanup_phase = 2; @@ -2356,22 +2359,27 @@ int filter_create_object(struct obd_device *obd, struct obdo *oa, GOTO(cleanup, rc); } + /* setting passed uid and gid */ + if (dchild->d_inode != NULL) { + if (uid) + dchild->d_inode->i_uid = uid; + if (gid) + dchild->d_inode->i_gid = gid; + if (uid || gid) + mark_inode_dirty(dchild->d_inode); + } + fsfilt_set_fs_flags(obd, dparent->d_inode, SM_DO_REC); - if (oa->o_id > filter_last_id(filter, group)) { - /* - * saving last created object id, it will be needed in recovery - * for deleting orphanes. - */ - filter_set_last_id(filter, group, oa->o_id); + /* save last created object id */ + filter_save_last_id(filter, group, id); - rc = filter_update_last_objid(obd, group, 0); - if (rc) { - CERROR("unable to write lastobjid, but " - "orphans were deleted, err = %d\n", - rc); - rc = 0; - } + rc = filter_update_last_objid(obd, group, 0); + if (rc) { + CERROR("unable to write lastobjid, but " + "orphans were deleted, err = %d\n", + rc); + rc = 0; } cleanup: switch(cleanup_phase) { @@ -2399,11 +2407,11 @@ out: RETURN(rc); } -struct dentry *filter_crow_object(struct obd_device *obd, - __u64 ogr, __u64 oid) +struct dentry * +filter_crow_object(struct obd_device *obd, __u64 ogr, + __u64 oid, obd_uid uid, obd_gid gid) { struct dentry *dentry; - struct obdo *oa; int rc = 0; ENTRY; @@ -2417,30 +2425,21 @@ struct dentry *filter_crow_object(struct obd_device *obd, f_dput(dentry); - /* allocate object as it does not exist */ - oa = obdo_alloc(); - if (oa == NULL) - RETURN(ERR_PTR(-ENOMEM)); - - oa->o_id = oid; - oa->o_gr = ogr; - oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP; - CDEBUG(D_INODE, "OSS object "LPU64"/"LPU64 - " does not exists - allocate now\n", + " does not exists - allocate it now\n", oid, ogr); - rc = filter_create_object(obd, oa, oa->o_gr); + rc = filter_create_object(obd, ogr, oid, uid, gid); if (rc) { CERROR("cannot create OSS object "LPU64"/"LPU64 - ", err = %d\n", oa->o_id, oa->o_gr, rc); - GOTO(out_free_oa, dentry = ERR_PTR(rc)); + ", err = %d\n", oid, ogr, rc); + RETURN(ERR_PTR(rc)); } /* lookup for just created object and return it to caller */ dentry = filter_id2dentry(obd, NULL, ogr, oid); if (IS_ERR(dentry)) - GOTO(out_free_oa, dentry); + RETURN(dentry); if (dentry->d_inode == NULL) { f_dput(dentry); @@ -2448,13 +2447,10 @@ struct dentry *filter_crow_object(struct obd_device *obd, CERROR("cannot find just created OSS object " LPU64"/"LPU64" err = %d\n", oid, ogr, (int)PTR_ERR(dentry)); - GOTO(out_free_oa, dentry); + RETURN(dentry); } - EXIT; -out_free_oa: - obdo_free(oa); - return dentry; + RETURN(dentry); } static int diff --git a/lustre/obdfilter/filter_internal.h b/lustre/obdfilter/filter_internal.h index 95583ae..9874000 100644 --- a/lustre/obdfilter/filter_internal.h +++ b/lustre/obdfilter/filter_internal.h @@ -112,7 +112,7 @@ int filter_common_setup(struct obd_device *, obd_count len, void *buf, char *option); struct dentry *filter_crow_object(struct obd_device *obd, __u64 ogr, - __u64 oid); + __u64 oid, obd_uid uid, obd_gid gid); int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry, struct obdo *oa, struct obd_trans_info *oti); @@ -120,8 +120,8 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry, int filter_setattr(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md *md, struct obd_trans_info *oti); -int filter_create_object(struct obd_device *obd, struct obdo *oa, - obd_gr group); +int filter_create_object(struct obd_device *obd, obd_gr group, obd_id id, + obd_uid uid, obd_gid gid); /* filter_lvb.c */ extern struct ldlm_valblock_ops filter_lvbo; diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c index 1c9cd4d..af7d8ff 100644 --- a/lustre/obdfilter/filter_io.c +++ b/lustre/obdfilter/filter_io.c @@ -506,6 +506,8 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa, struct fsfilt_objinfo fso; struct obd_device *obd; obd_size left; + obd_uid uid; + obd_gid gid; void *iobuf; ENTRY; @@ -522,27 +524,18 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa, obd = exp->exp_obd; push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + uid = oa->o_valid & OBD_MD_FLUID ? oa->o_uid : 0; + gid = oa->o_valid & OBD_MD_FLGID ? oa->o_gid : 0; + /* make sure that object is already allocated */ dentry = filter_crow_object(obd, obj->ioo_gr, - obj->ioo_id); + obj->ioo_id, uid, gid); if (IS_ERR(dentry)) GOTO(cleanup, rc = PTR_ERR(dentry)); cleanup_phase = 2; - /* - * setting attrs passed along with write requests (owner/group). We - * goind it here as object should not exist with wrong owner/group as - * this may break quotas. --umka - */ - rc = filter_setattr_internal(exp, dentry, oa, NULL); - if (rc) { - CERROR("cannot set attrs on write, err %d\n", - rc); - GOTO(cleanup, rc); - } - fso.fso_dentry = dentry; fso.fso_bufcnt = obj->ioo_bufcnt; diff --git a/lustre/obdfilter/filter_io_24.c b/lustre/obdfilter/filter_io_24.c index 4b2d012..0010961 100644 --- a/lustre/obdfilter/filter_io_24.c +++ b/lustre/obdfilter/filter_io_24.c @@ -38,20 +38,6 @@ #include #include "filter_internal.h" - -/* We should only change the file mtime (and not the ctime, like - * update_inode_times() in generic_file_write()) when we only change data. */ -void inode_update_time(struct inode *inode, int ctime_too) -{ - time_t now = CURRENT_TIME; - if (inode->i_mtime == now && (!ctime_too || inode->i_ctime == now)) - return; - inode->i_mtime = now; - if (ctime_too) - inode->i_ctime = now; - mark_inode_dirty_sync(inode); -} - /* Bug 2254 -- this is better done in ext3_map_inode_page, but this * workaround will suffice until everyone has upgraded their kernels */ static void check_pending_bhs(unsigned long *blocks, int nr_pages, dev_t dev,