4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2012, 2015, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #define DEBUG_SUBSYSTEM S_LOV
39 #include <libcfs/libcfs.h>
41 #include <obd_class.h>
42 #include "lov_internal.h"
44 /** Merge the lock value block(&lvb) attributes and KMS from each of the
45 * stripes in a file into a single lvb. It is expected that the caller
46 * initializes the current atime, mtime, ctime to avoid regressing a more
47 * uptodate time on the local client.
49 int lov_merge_lvb_kms(struct lov_stripe_md *lsm,
50 struct ost_lvb *lvb, __u64 *kms_place)
55 s64 current_mtime = lvb->lvb_mtime;
56 s64 current_atime = lvb->lvb_atime;
57 s64 current_ctime = lvb->lvb_ctime;
61 assert_spin_locked(&lsm->lsm_lock);
62 LASSERT(lsm->lsm_lock_owner == current_pid());
64 CDEBUG(D_INODE, "MDT ID "DOSTID" initial value: s="LPU64" m="LPU64
65 " a="LPU64" c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi),
66 lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime,
68 for (i = 0; i < lsm->lsm_stripe_count; i++) {
69 struct lov_oinfo *loi = lsm->lsm_oinfo[i];
73 if (OST_LVB_IS_ERR(loi->loi_lvb.lvb_blocks)) {
74 rc = OST_LVB_GET_ERR(loi->loi_lvb.lvb_blocks);
78 tmpsize = loi->loi_kms;
79 lov_size = lov_stripe_size(lsm, tmpsize, i);
83 if (loi->loi_lvb.lvb_size > tmpsize)
84 tmpsize = loi->loi_lvb.lvb_size;
86 lov_size = lov_stripe_size(lsm, tmpsize, i);
89 /* merge blocks, mtime, atime */
90 blocks += loi->loi_lvb.lvb_blocks;
91 if (loi->loi_lvb.lvb_mtime > current_mtime)
92 current_mtime = loi->loi_lvb.lvb_mtime;
93 if (loi->loi_lvb.lvb_atime > current_atime)
94 current_atime = loi->loi_lvb.lvb_atime;
95 if (loi->loi_lvb.lvb_ctime > current_ctime)
96 current_ctime = loi->loi_lvb.lvb_ctime;
98 CDEBUG(D_INODE, "MDT ID "DOSTID" on OST[%u]: s="LPU64" m="LPU64
99 " a="LPU64" c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi),
100 loi->loi_ost_idx, loi->loi_lvb.lvb_size,
101 loi->loi_lvb.lvb_mtime, loi->loi_lvb.lvb_atime,
102 loi->loi_lvb.lvb_ctime, loi->loi_lvb.lvb_blocks);
106 lvb->lvb_size = size;
107 lvb->lvb_blocks = blocks;
108 lvb->lvb_mtime = current_mtime;
109 lvb->lvb_atime = current_atime;
110 lvb->lvb_ctime = current_ctime;