Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 1 | /* |
| 2 | * GPL HEADER START |
| 3 | * |
| 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 5 | * |
| 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. |
| 9 | * |
| 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). |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * version 2 along with this program; If not, see |
Oleg Drokin | 6a5b99a | 2016-06-14 23:33:40 -0400 | [diff] [blame] | 18 | * http://www.gnu.org/licenses/gpl-2.0.html |
Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 19 | * |
Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 20 | * GPL HEADER END |
| 21 | */ |
| 22 | /* |
| 23 | * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. |
| 24 | * Use is subject to license terms. |
| 25 | * |
| 26 | * Copyright (c) 2011, 2012, Intel Corporation. |
| 27 | */ |
| 28 | /* |
| 29 | * This file is part of Lustre, http://www.lustre.org/ |
| 30 | * Lustre is a trademark of Sun Microsystems, Inc. |
| 31 | * |
| 32 | * lustre/obdclass/linux/linux-obdo.c |
| 33 | * |
| 34 | * Object Devices Class Driver |
| 35 | * These are the only exported functions, they provide some generic |
| 36 | * infrastructure for managing object devices |
| 37 | */ |
| 38 | |
| 39 | #define DEBUG_SUBSYSTEM S_CLASS |
| 40 | |
| 41 | #include <linux/module.h> |
Greg Kroah-Hartman | 610f737 | 2014-07-11 22:15:24 -0700 | [diff] [blame] | 42 | #include "../../include/obd_class.h" |
| 43 | #include "../../include/lustre/lustre_idl.h" |
Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 44 | |
| 45 | #include <linux/fs.h> |
Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 46 | |
Oleg Drokin | 21aef7d | 2014-08-15 12:55:56 -0400 | [diff] [blame] | 47 | void obdo_refresh_inode(struct inode *dst, struct obdo *src, u32 valid) |
Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 48 | { |
| 49 | valid &= src->o_valid; |
| 50 | |
| 51 | if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME)) |
| 52 | CDEBUG(D_INODE, |
Greg Kroah-Hartman | 55f5a82 | 2014-07-12 20:26:07 -0700 | [diff] [blame] | 53 | "valid %#llx, cur time %lu/%lu, new %llu/%llu\n", |
Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 54 | src->o_valid, LTIME_S(dst->i_mtime), |
| 55 | LTIME_S(dst->i_ctime), src->o_mtime, src->o_ctime); |
| 56 | |
| 57 | if (valid & OBD_MD_FLATIME && src->o_atime > LTIME_S(dst->i_atime)) |
| 58 | LTIME_S(dst->i_atime) = src->o_atime; |
| 59 | if (valid & OBD_MD_FLMTIME && src->o_mtime > LTIME_S(dst->i_mtime)) |
| 60 | LTIME_S(dst->i_mtime) = src->o_mtime; |
| 61 | if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(dst->i_ctime)) |
| 62 | LTIME_S(dst->i_ctime) = src->o_ctime; |
| 63 | if (valid & OBD_MD_FLSIZE) |
| 64 | i_size_write(dst, src->o_size); |
| 65 | /* optimum IO size */ |
| 66 | if (valid & OBD_MD_FLBLKSZ && src->o_blksize > (1 << dst->i_blkbits)) |
| 67 | dst->i_blkbits = ffs(src->o_blksize) - 1; |
| 68 | |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 69 | if (dst->i_blkbits < PAGE_SHIFT) |
| 70 | dst->i_blkbits = PAGE_SHIFT; |
Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 71 | |
| 72 | /* allocation of space */ |
| 73 | if (valid & OBD_MD_FLBLOCKS && src->o_blocks > dst->i_blocks) |
| 74 | /* |
| 75 | * XXX shouldn't overflow be checked here like in |
| 76 | * obdo_to_inode(). |
| 77 | */ |
| 78 | dst->i_blocks = src->o_blocks; |
| 79 | } |
| 80 | EXPORT_SYMBOL(obdo_refresh_inode); |