1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
5 * Use is subject to license terms.
7 * Copyright (c) 2012, 2017, Intel Corporation.
11 * This file is part of Lustre, http://www.lustre.org/
14 #define DEBUG_SUBSYSTEM S_LOV
16 #include <libcfs/libcfs.h>
17 #include <cl_object.h>
18 #include <obd_class.h>
19 #include "lov_internal.h"
21 /** Merge the lock value block(&lvb) attributes and KMS from each of the
22 * stripes in a file into a single lvb. It is expected that the caller
23 * initializes the current atime, mtime, ctime to avoid regressing a more
24 * uptodate time on the local client.
26 int lov_merge_lvb_kms(struct lov_stripe_md *lsm, int index,
29 struct lov_stripe_md_entry *lse = lsm->lsm_entries[index];
33 /* XXX: timestamps can be negative by sanity:test_39m,
35 s64 current_mtime = LLONG_MIN;
36 s64 current_atime = LLONG_MIN;
37 s64 current_ctime = LLONG_MIN;
41 assert_spin_locked(&lsm->lsm_lock);
42 LASSERT(lsm->lsm_lock_owner == current->pid);
43 for (i = 0; i < lse->lsme_stripe_count; i++) {
44 struct lov_oinfo *loi = lse->lsme_oinfo[i];
48 if (OST_LVB_IS_ERR(loi->loi_lvb.lvb_blocks)) {
49 rc = OST_LVB_GET_ERR(loi->loi_lvb.lvb_blocks);
53 if (loi->loi_kms_valid) {
54 attr->cat_kms_valid = 1;
55 tmpsize = loi->loi_kms;
59 lov_size = lov_stripe_size(lsm, index, tmpsize, i);
63 if (loi->loi_lvb.lvb_size > tmpsize)
64 tmpsize = loi->loi_lvb.lvb_size;
66 lov_size = lov_stripe_size(lsm, index, tmpsize, i);
69 /* merge blocks, mtime, atime */
70 blocks += loi->loi_lvb.lvb_blocks;
71 if (loi->loi_lvb.lvb_mtime > current_mtime)
72 current_mtime = loi->loi_lvb.lvb_mtime;
73 if (loi->loi_lvb.lvb_atime > current_atime)
74 current_atime = loi->loi_lvb.lvb_atime;
75 if (loi->loi_lvb.lvb_ctime > current_ctime)
76 current_ctime = loi->loi_lvb.lvb_ctime;
78 CDEBUG(D_INODE, "MDT ID "DOSTID" on OST[%u]: s=%llu (%d) m=%llu"
79 " a=%llu c=%llu b=%llu\n", POSTID(&lsm->lsm_oi),
80 loi->loi_ost_idx, loi->loi_lvb.lvb_size,
81 loi->loi_kms_valid, loi->loi_lvb.lvb_mtime,
82 loi->loi_lvb.lvb_atime, loi->loi_lvb.lvb_ctime,
83 loi->loi_lvb.lvb_blocks);
88 attr->cat_size = size;
89 attr->cat_mtime = current_mtime;
90 attr->cat_atime = current_atime;
91 attr->cat_ctime = current_ctime;
92 attr->cat_blocks = blocks;