+ CDEBUG(D_INODE, "truncating file %.*s to %lld\n", (int)strlen(name),
+ name, (long long)length);
+ dchild = ll_lookup_one_len(name, dir, strlen(name));
+ if (IS_ERR(dchild))
+ GOTO(out, err = PTR_ERR(dchild));
+
+ if (dchild->d_inode) {
+ int old_mode = dchild->d_inode->i_mode;
+ if (S_ISDIR(old_mode)) {
+ CERROR("found %s (%lu/%u) is mode %o\n", name,
+ dchild->d_inode->i_ino,
+ dchild->d_inode->i_generation, old_mode);
+ GOTO(out_dput, err = -EISDIR);
+ }
+
+ newattrs.ia_size = length;
+ newattrs.ia_valid = ATTR_SIZE;
+ err = l_notify_change(mnt, dchild, &newattrs);
+ }
+ EXIT;
+out_dput:
+ dput(dchild);
+out:
+ return err;
+}
+EXPORT_SYMBOL(simple_truncate);
+
+#ifdef LUSTRE_KERNEL_VERSION
+#ifndef HAVE_CLEAR_RDONLY_ON_PUT
+#error rdonly patchset must be updated [cfs bz11248]
+#endif
+void dev_set_rdonly(lvfs_sbdev_type dev);
+int dev_check_rdonly(lvfs_sbdev_type dev);
+
+void __lvfs_set_rdonly(lvfs_sbdev_type dev, lvfs_sbdev_type jdev)
+{
+ if (jdev && (jdev != dev)) {
+ CDEBUG(D_IOCTL | D_HA, "set journal dev %lx rdonly\n",
+ (long)jdev);
+ dev_set_rdonly(jdev);
+ }
+ CDEBUG(D_IOCTL | D_HA, "set dev %lx rdonly\n", (long)dev);
+ dev_set_rdonly(dev);
+}
+
+int lvfs_check_rdonly(lvfs_sbdev_type dev)
+{
+ return dev_check_rdonly(dev);
+}
+
+EXPORT_SYMBOL(__lvfs_set_rdonly);
+EXPORT_SYMBOL(lvfs_check_rdonly);
+
+int lvfs_check_io_health(struct obd_device *obd, struct file *file)
+{
+ char *write_page = NULL;
+ loff_t offset = 0;
+ int rc = 0;
+ ENTRY;
+
+ OBD_ALLOC(write_page, CFS_PAGE_SIZE);
+ if (!write_page)
+ RETURN(-ENOMEM);