From 523f951fefccb756a3a093c69572e7a3cce4bdfa Mon Sep 17 00:00:00 2001 From: phil Date: Sat, 26 Feb 2005 05:57:33 +0000 Subject: [PATCH] b=5654 Landing the purely mechanical parts of bug 5654, to make the patch smaller for inspection. Change obd_increase_kms to obd_adjust_kms to allow growing or shrinking the kms. --- lustre/ChangeLog | 1 + lustre/include/linux/obd.h | 4 ++-- lustre/include/linux/obd_class.h | 11 ++++++----- lustre/liblustre/rw.c | 5 +---- lustre/llite/rw.c | 2 +- lustre/llite/rw24.c | 2 +- lustre/lov/lov_internal.h | 2 ++ lustre/lov/lov_merge.c | 17 ++++++++++++++--- lustre/lov/lov_obd.c | 5 +---- lustre/obdclass/lprocfs_status.c | 2 +- 10 files changed, 30 insertions(+), 21 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 922919a..87e32a5 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -44,6 +44,7 @@ tbd Cluster File Systems, Inc. - mmap locking landed again, after considerable improvement (2828) - fix lustre/lustrefs init scripts for SuSE (patch from Scali, 5702) - don't hold the pinger_sem in ptlrpc_pinger_sending_on_import + - change obd_increase_kms to obd_adjust_kms (up or down) (5654) 2004-11-23 Cluster File Systems, Inc. * version 1.4.0 diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index b0d2685..a9704f5 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -620,8 +620,8 @@ struct obd_ops { int (*o_teardown_async_page)(struct obd_export *exp, struct lov_stripe_md *lsm, struct lov_oinfo *loi, void *cookie); - int (*o_increase_kms)(struct obd_export *exp, struct lov_stripe_md *lsm, - obd_off size); + int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm, + obd_off size, int shrink); int (*o_punch)(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md *ea, obd_size start, obd_size end, struct obd_trans_info *oti); diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 9b393f0..cfbd032 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -765,16 +765,17 @@ static inline int obd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa, RETURN(rc); } -static inline int obd_increase_kms(struct obd_export *exp, - struct lov_stripe_md *lsm, obd_off size) +static inline int obd_adjust_kms(struct obd_export *exp, + struct lov_stripe_md *lsm, obd_off size, + int shrink) { int rc; ENTRY; - OBD_CHECK_OP(exp->exp_obd, increase_kms, -EOPNOTSUPP); - OBD_COUNTER_INCREMENT(exp->exp_obd, increase_kms); + OBD_CHECK_OP(exp->exp_obd, adjust_kms, -EOPNOTSUPP); + OBD_COUNTER_INCREMENT(exp->exp_obd, adjust_kms); - rc = OBP(exp->exp_obd, increase_kms)(exp, lsm, size); + rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink); RETURN(rc); } diff --git a/lustre/liblustre/rw.c b/lustre/liblustre/rw.c index a59dba0..ea99362 100644 --- a/lustre/liblustre/rw.c +++ b/lustre/liblustre/rw.c @@ -697,9 +697,6 @@ out_cleanup: RETURN(ERR_PTR(rc)); } -void lov_increase_kms(struct obd_export *exp, struct lov_stripe_md *lsm, - obd_off size); - struct llu_sysio_callback_args* llu_file_write(struct inode *inode, const struct iovec *iovec, size_t iovlen, loff_t pos) @@ -758,7 +755,7 @@ llu_file_write(struct inode *inode, const struct iovec *iovec, /* save cookie */ lsca->cookies[lsca->ncookies++] = cookie; pos += count; - lov_increase_kms(exp, lsm, pos); + obd_adjust_kms(exp, lsm, pos, 0); /* file size grow */ if (pos > lli->lli_st_size) lli->lli_st_size = pos; diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index cd34804..3e947dd 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -642,7 +642,7 @@ int ll_commit_write(struct file *file, struct page *page, unsigned from, out: size = (((obd_off)page->index) << PAGE_SHIFT) + to; if (rc == 0) { - obd_increase_kms(exp, lsm, size); + obd_adjust_kms(exp, lsm, size, 0); if (size > inode->i_size) inode->i_size = size; SetPageUptodate(page); diff --git a/lustre/llite/rw24.c b/lustre/llite/rw24.c index aa8e708..0b7505e 100644 --- a/lustre/llite/rw24.c +++ b/lustre/llite/rw24.c @@ -127,7 +127,7 @@ static int ll_direct_IO_24(int rw, if (rc == 0) { rc = iobuf->length; if (rw == WRITE) - obd_increase_kms(ll_i2obdexp(inode), lsm, offset); + obd_adjust_kms(ll_i2obdexp(inode), lsm, offset, 0); } OBD_FREE(pga, sizeof(*pga) * iobuf->nr_pages); diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 635a913..3127d08 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -113,6 +113,8 @@ static inline void lov_llh_put(struct lov_lock_handles *llh) /* lov_merge.c */ void lov_merge_attrs(struct obdo *tgt, struct obdo *src, obd_flag valid, struct lov_stripe_md *lsm, int stripeno, int *set); +int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, + obd_off size, int shrink); /* lov_offset.c */ obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size, diff --git a/lustre/lov/lov_merge.c b/lustre/lov/lov_merge.c index e4e40bd..082dae3 100644 --- a/lustre/lov/lov_merge.c +++ b/lustre/lov/lov_merge.c @@ -88,14 +88,26 @@ __u64 lov_merge_mtime(struct lov_stripe_md *lsm, __u64 current_time) } EXPORT_SYMBOL(lov_merge_mtime); -int lov_increase_kms(struct obd_export *exp, struct lov_stripe_md *lsm, - obd_off size) +/* Must be called with the inode's lli_size_sem held. */ +int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, + obd_off size, int shrink) { struct lov_oinfo *loi; int stripe = 0; __u64 kms; ENTRY; + if (shrink) { + struct lov_oinfo *loi; + int i = 0; + for (loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; + i++, loi++) { + kms = lov_size_to_stripe(lsm, size, i); + loi->loi_kms = loi->loi_rss = kms; + } + RETURN(0); + } + if (size > 0) stripe = lov_stripe_number(lsm, size - 1); kms = lov_size_to_stripe(lsm, size, stripe); @@ -108,7 +120,6 @@ int lov_increase_kms(struct obd_export *exp, struct lov_stripe_md *lsm, RETURN(0); } -EXPORT_SYMBOL(lov_increase_kms); void lov_merge_attrs(struct obdo *tgt, struct obdo *src, obd_flag valid, struct lov_stripe_md *lsm, int stripeno, int *set) diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 55166c2..3d4eb32 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1806,9 +1806,6 @@ int lov_complete_many(struct obd_export *exp, struct lov_stripe_md *lsm, } #endif -int lov_increase_kms(struct obd_export *exp, struct lov_stripe_md *lsm, - obd_off size); - struct obd_ops lov_obd_ops = { .o_owner = THIS_MODULE, .o_setup = lov_setup, @@ -1831,7 +1828,7 @@ struct obd_ops lov_obd_ops = { .o_queue_group_io = lov_queue_group_io, .o_trigger_group_io = lov_trigger_group_io, .o_teardown_async_page = lov_teardown_async_page, - .o_increase_kms = lov_increase_kms, + .o_adjust_kms = lov_adjust_kms, .o_punch = lov_punch, .o_sync = lov_sync, .o_enqueue = lov_enqueue, diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 9ab5fb4..7a5d0c9 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -632,7 +632,7 @@ int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats) LPROCFS_OBD_OP_INIT(num_private_stats, stats, trigger_group_io); LPROCFS_OBD_OP_INIT(num_private_stats, stats, set_async_flags); LPROCFS_OBD_OP_INIT(num_private_stats, stats, teardown_async_page); - LPROCFS_OBD_OP_INIT(num_private_stats, stats, increase_kms); + LPROCFS_OBD_OP_INIT(num_private_stats, stats, adjust_kms); LPROCFS_OBD_OP_INIT(num_private_stats, stats, punch); LPROCFS_OBD_OP_INIT(num_private_stats, stats, sync); LPROCFS_OBD_OP_INIT(num_private_stats, stats, migrate); -- 1.8.3.1